LLVM 20.0.0git
CodeGenPassBuilder.h
Go to the documentation of this file.
1//===- Construction of codegen pass pipelines ------------------*- C++ -*--===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8/// \file
9///
10/// Interfaces for producing common pass manager configurations.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_PASSES_CODEGENPASSBUILDER_H
15#define LLVM_PASSES_CODEGENPASSBUILDER_H
16
18#include "llvm/ADT/StringRef.h"
60#include "llvm/IR/PassManager.h"
61#include "llvm/IR/Verifier.h"
63#include "llvm/MC/MCAsmInfo.h"
66#include "llvm/Support/Debug.h"
67#include "llvm/Support/Error.h"
81#include <cassert>
82#include <type_traits>
83#include <utility>
84
85namespace llvm {
86
87// FIXME: Dummy target independent passes definitions that have not yet been
88// ported to new pass manager. Once they do, remove these.
89#define DUMMY_FUNCTION_PASS(NAME, PASS_NAME) \
90 struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
91 template <typename... Ts> PASS_NAME(Ts &&...) {} \
92 PreservedAnalyses run(Function &, FunctionAnalysisManager &) { \
93 return PreservedAnalyses::all(); \
94 } \
95 };
96#define DUMMY_MACHINE_MODULE_PASS(NAME, PASS_NAME) \
97 struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
98 template <typename... Ts> PASS_NAME(Ts &&...) {} \
99 PreservedAnalyses run(Module &, ModuleAnalysisManager &) { \
100 return PreservedAnalyses::all(); \
101 } \
102 };
103#define DUMMY_MACHINE_FUNCTION_PASS(NAME, PASS_NAME) \
104 struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
105 template <typename... Ts> PASS_NAME(Ts &&...) {} \
106 PreservedAnalyses run(MachineFunction &, \
107 MachineFunctionAnalysisManager &) { \
108 return PreservedAnalyses::all(); \
109 } \
110 };
111#include "llvm/Passes/MachinePassRegistry.def"
112
113/// This class provides access to building LLVM's passes.
114///
115/// Its members provide the baseline state available to passes during their
116/// construction. The \c MachinePassRegistry.def file specifies how to construct
117/// all of the built-in passes, and those may reference these members during
118/// construction.
119template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
120public:
121 explicit CodeGenPassBuilder(TargetMachineT &TM,
122 const CGPassBuilderOption &Opts,
124 : TM(TM), Opt(Opts), PIC(PIC) {
125 // Target could set CGPassBuilderOption::MISchedPostRA to true to achieve
126 // substitutePass(&PostRASchedulerID, &PostMachineSchedulerID)
127
128 // Target should override TM.Options.EnableIPRA in their target-specific
129 // LLVMTM ctor. See TargetMachine::setGlobalISel for example.
130 if (Opt.EnableIPRA)
131 TM.Options.EnableIPRA = *Opt.EnableIPRA;
132
134 TM.Options.GlobalISelAbort = *Opt.EnableGlobalISelAbort;
135
138 }
139
141 raw_pwrite_stream *DwoOut,
142 CodeGenFileType FileType) const;
143
145 return PIC;
146 }
147
148protected:
149 template <typename PassT>
150 using has_required_t = decltype(std::declval<PassT &>().isRequired());
151
152 template <typename PassT>
153 using is_module_pass_t = decltype(std::declval<PassT &>().run(
154 std::declval<Module &>(), std::declval<ModuleAnalysisManager &>()));
155
156 template <typename PassT>
157 using is_function_pass_t = decltype(std::declval<PassT &>().run(
158 std::declval<Function &>(), std::declval<FunctionAnalysisManager &>()));
159
160 template <typename PassT>
161 using is_machine_function_pass_t = decltype(std::declval<PassT &>().run(
162 std::declval<MachineFunction &>(),
163 std::declval<MachineFunctionAnalysisManager &>()));
164
165 // Function object to maintain state while adding codegen IR passes.
166 // TODO: add a Function -> MachineFunction adaptor and merge
167 // AddIRPass/AddMachinePass so we can have a function pipeline that runs both
168 // function passes and machine function passes.
169 class AddIRPass {
170 public:
171 AddIRPass(ModulePassManager &MPM, const DerivedT &PB) : MPM(MPM), PB(PB) {}
173 if (!FPM.isEmpty())
174 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
175 }
176
177 template <typename PassT>
178 void operator()(PassT &&Pass, StringRef Name = PassT::name()) {
181 "Only module pass and function pass are supported.");
182 bool Required = false;
184 Required = PassT::isRequired();
185 if (!PB.runBeforeAdding(Name) && !Required)
186 return;
187
188 // Add Function Pass
190 FPM.addPass(std::forward<PassT>(Pass));
191 } else {
192 // Add Module Pass
193 if (!FPM.isEmpty()) {
194 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
195 FPM = FunctionPassManager();
196 }
197
198 MPM.addPass(std::forward<PassT>(Pass));
199 }
200 }
201
202 private:
205 const DerivedT &PB;
206 };
207
208 // Function object to maintain state while adding codegen machine passes.
210 public:
211 AddMachinePass(ModulePassManager &MPM, const DerivedT &PB)
212 : MPM(MPM), PB(PB) {}
214 if (!MFPM.isEmpty()) {
216 FPM.addPass(
219 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
220 }
221 }
222
223 template <typename PassT>
224 void operator()(PassT &&Pass, bool Force = false,
225 StringRef Name = PassT::name()) {
228 "Only module pass and function pass are supported.");
229
230 if (!Force && !PB.runBeforeAdding(Name))
231 return;
232
233 // Add Function Pass
235 MFPM.addPass(std::forward<PassT>(Pass));
236 } else {
237 // Add Module Pass
238 if (!MFPM.isEmpty()) {
242 }
243
244 MPM.addPass(std::forward<PassT>(Pass));
245 }
246
247 for (auto &C : PB.AfterCallbacks)
248 C(Name, MFPM);
249 }
250
251 private:
254 const DerivedT &PB;
255 };
256
257 TargetMachineT &TM;
260
261 template <typename TMC> TMC &getTM() const { return static_cast<TMC &>(TM); }
262 CodeGenOptLevel getOptLevel() const { return TM.getOptLevel(); }
263
264 /// Check whether or not GlobalISel should abort on error.
265 /// When this is disabled, GlobalISel will fall back on SDISel instead of
266 /// erroring out.
268 return TM.Options.GlobalISelAbort == GlobalISelAbortMode::Enable;
269 }
270
271 /// Check whether or not a diagnostic should be emitted when GlobalISel
272 /// uses the fallback path. In other words, it will emit a diagnostic
273 /// when GlobalISel failed and isGlobalISelAbortEnabled is false.
275 return TM.Options.GlobalISelAbort == GlobalISelAbortMode::DisableWithDiag;
276 }
277
278 /// addInstSelector - This method should install an instruction selector pass,
279 /// which converts from LLVM code to machine instructions.
281 return make_error<StringError>("addInstSelector is not overridden",
283 }
284
285 /// Target can override this to add GlobalMergePass before all IR passes.
287
288 /// Add passes that optimize instruction level parallelism for out-of-order
289 /// targets. These passes are run while the machine code is still in SSA
290 /// form, so they can use MachineTraceMetrics to control their heuristics.
291 ///
292 /// All passes added here should preserve the MachineDominatorTree,
293 /// MachineLoopInfo, and MachineTraceMetrics analyses.
294 void addILPOpts(AddMachinePass &) const {}
295
296 /// This method may be implemented by targets that want to run passes
297 /// immediately before register allocation.
299
300 /// addPreRewrite - Add passes to the optimized register allocation pipeline
301 /// after register allocation is complete, but before virtual registers are
302 /// rewritten to physical registers.
303 ///
304 /// These passes must preserve VirtRegMap and LiveIntervals, and when running
305 /// after RABasic or RAGreedy, they should take advantage of LiveRegMatrix.
306 /// When these passes run, VirtRegMap contains legal physreg assignments for
307 /// all virtual registers.
308 ///
309 /// Note if the target overloads addRegAssignAndRewriteOptimized, this may not
310 /// be honored. This is also not generally used for the fast variant,
311 /// where the allocation and rewriting are done in one pass.
313
314 /// Add passes to be run immediately after virtual registers are rewritten
315 /// to physical registers.
317
318 /// This method may be implemented by targets that want to run passes after
319 /// register allocation pass pipeline but before prolog-epilog insertion.
321
322 /// This method may be implemented by targets that want to run passes after
323 /// prolog-epilog insertion and before the second instruction scheduling pass.
325
326 /// This pass may be implemented by targets that want to run passes
327 /// immediately before machine code is emitted.
329
330 /// Targets may add passes immediately before machine code is emitted in this
331 /// callback. This is called even later than `addPreEmitPass`.
332 // FIXME: Rename `addPreEmitPass` to something more sensible given its actual
333 // position and remove the `2` suffix here as this callback is what
334 // `addPreEmitPass` *should* be but in reality isn't.
336
337 /// {{@ For GlobalISel
338 ///
339
340 /// addPreISel - This method should add any "last minute" LLVM->LLVM
341 /// passes (which are run just before instruction selector).
342 void addPreISel(AddIRPass &) const {
343 llvm_unreachable("addPreISel is not overridden");
344 }
345
346 /// This method should install an IR translator pass, which converts from
347 /// LLVM code to machine instructions with possibly generic opcodes.
349 return make_error<StringError>("addIRTranslator is not overridden",
351 }
352
353 /// This method may be implemented by targets that want to run passes
354 /// immediately before legalization.
356
357 /// This method should install a legalize pass, which converts the instruction
358 /// sequence into one that can be selected by the target.
360 return make_error<StringError>("addLegalizeMachineIR is not overridden",
362 }
363
364 /// This method may be implemented by targets that want to run passes
365 /// immediately before the register bank selection.
367
368 /// This method should install a register bank selector pass, which
369 /// assigns register banks to virtual registers without a register
370 /// class or register banks.
372 return make_error<StringError>("addRegBankSelect is not overridden",
374 }
375
376 /// This method may be implemented by targets that want to run passes
377 /// immediately before the (global) instruction selection.
379
380 /// This method should install a (global) instruction selector pass, which
381 /// converts possibly generic instructions to fully target-specific
382 /// instructions, thereby constraining all generic virtual registers to
383 /// register classes.
385 return make_error<StringError>(
386 "addGlobalInstructionSelect is not overridden",
388 }
389 /// @}}
390
391 /// High level function that adds all passes necessary to go from llvm IR
392 /// representation to the MI representation.
393 /// Adds IR based lowering and target specific optimization passes and finally
394 /// the core instruction selection passes.
395 void addISelPasses(AddIRPass &) const;
396
397 /// Add the actual instruction selection passes. This does not include
398 /// preparation passes on IR.
399 Error addCoreISelPasses(AddMachinePass &) const;
400
401 /// Add the complete, standard set of LLVM CodeGen passes.
402 /// Fully developed targets will not generally override this.
403 Error addMachinePasses(AddMachinePass &) const;
404
405 /// Add passes to lower exception handling for the code generator.
406 void addPassesToHandleExceptions(AddIRPass &) const;
407
408 /// Add common target configurable passes that perform LLVM IR to IR
409 /// transforms following machine independent optimization.
410 void addIRPasses(AddIRPass &) const;
411
412 /// Add pass to prepare the LLVM IR for code generation. This should be done
413 /// before exception handling preparation passes.
414 void addCodeGenPrepare(AddIRPass &) const;
415
416 /// Add common passes that perform LLVM IR to IR transforms in preparation for
417 /// instruction selection.
418 void addISelPrepare(AddIRPass &) const;
419
420 /// Methods with trivial inline returns are convenient points in the common
421 /// codegen pass pipeline where targets may insert passes. Methods with
422 /// out-of-line standard implementations are major CodeGen stages called by
423 /// addMachinePasses. Some targets may override major stages when inserting
424 /// passes is insufficient, but maintaining overriden stages is more work.
425 ///
426
427 /// addMachineSSAOptimization - Add standard passes that optimize machine
428 /// instructions in SSA form.
429 void addMachineSSAOptimization(AddMachinePass &) const;
430
431 /// addFastRegAlloc - Add the minimum set of target-independent passes that
432 /// are required for fast register allocation.
433 Error addFastRegAlloc(AddMachinePass &) const;
434
435 /// addOptimizedRegAlloc - Add passes related to register allocation.
436 /// LLVMTargetMachine provides standard regalloc passes for most targets.
437 void addOptimizedRegAlloc(AddMachinePass &) const;
438
439 /// Add passes that optimize machine instructions after register allocation.
440 void addMachineLateOptimization(AddMachinePass &) const;
441
442 /// addGCPasses - Add late codegen passes that analyze code for garbage
443 /// collection. This should return true if GC info should be printed after
444 /// these passes.
446
447 /// Add standard basic block placement passes.
448 void addBlockPlacement(AddMachinePass &) const;
449
451 std::function<Expected<std::unique_ptr<MCStreamer>>(MCContext &)>;
453 llvm_unreachable("addAsmPrinter is not overridden");
454 }
455
456 /// Utilities for targets to add passes to the pass manager.
457 ///
458
459 /// createTargetRegisterAllocator - Create the register allocator pass for
460 /// this target at the current optimization level.
461 void addTargetRegisterAllocator(AddMachinePass &, bool Optimized) const;
462
463 /// addMachinePasses helper to create the target-selected or overriden
464 /// regalloc pass.
465 void addRegAllocPass(AddMachinePass &, bool Optimized) const;
466
467 /// Add core register alloator passes which do the actual register assignment
468 /// and rewriting. \returns true if any passes were added.
469 Error addRegAssignmentFast(AddMachinePass &) const;
470 Error addRegAssignmentOptimized(AddMachinePass &) const;
471
472 /// Allow the target to disable a specific pass by default.
473 /// Backend can declare unwanted passes in constructor.
474 template <typename... PassTs> void disablePass() {
475 BeforeCallbacks.emplace_back(
476 [](StringRef Name) { return ((Name != PassTs::name()) && ...); });
477 }
478
479 /// Insert InsertedPass pass after TargetPass pass.
480 /// Only machine function passes are supported.
481 template <typename TargetPassT, typename InsertedPassT>
482 void insertPass(InsertedPassT &&Pass) {
483 AfterCallbacks.emplace_back(
484 [&](StringRef Name, MachineFunctionPassManager &MFPM) mutable {
485 if (Name == TargetPassT::name())
486 MFPM.addPass(std::forward<InsertedPassT>(Pass));
487 });
488 }
489
490private:
491 DerivedT &derived() { return static_cast<DerivedT &>(*this); }
492 const DerivedT &derived() const {
493 return static_cast<const DerivedT &>(*this);
494 }
495
496 bool runBeforeAdding(StringRef Name) const {
497 bool ShouldAdd = true;
498 for (auto &C : BeforeCallbacks)
499 ShouldAdd &= C(Name);
500 return ShouldAdd;
501 }
502
503 void setStartStopPasses(const TargetPassConfig::StartStopInfo &Info) const;
504
505 Error verifyStartStop(const TargetPassConfig::StartStopInfo &Info) const;
506
507 mutable SmallVector<llvm::unique_function<bool(StringRef)>, 4>
508 BeforeCallbacks;
509 mutable SmallVector<
511 AfterCallbacks;
512
513 /// Helper variable for `-start-before/-start-after/-stop-before/-stop-after`
514 mutable bool Started = true;
515 mutable bool Stopped = true;
516};
517
518template <typename Derived, typename TargetMachineT>
521 CodeGenFileType FileType) const {
522 auto StartStopInfo = TargetPassConfig::getStartStopInfo(*PIC);
523 if (!StartStopInfo)
524 return StartStopInfo.takeError();
525 setStartStopPasses(*StartStopInfo);
526
528 bool PrintMIR = !PrintAsm && FileType != CodeGenFileType::Null;
529
530 {
531 AddIRPass addIRPass(MPM, derived());
535 addISelPasses(addIRPass);
536 }
537
538 AddMachinePass addPass(MPM, derived());
539
540 if (PrintMIR)
541 addPass(PrintMIRPreparePass(Out), /*Force=*/true);
542
543 if (auto Err = addCoreISelPasses(addPass))
544 return std::move(Err);
545
546 if (auto Err = derived().addMachinePasses(addPass))
547 return std::move(Err);
548
549 if (PrintAsm) {
550 derived().addAsmPrinter(
551 addPass, [this, &Out, DwoOut, FileType](MCContext &Ctx) {
552 return this->TM.createMCStreamer(Out, DwoOut, FileType, Ctx);
553 });
554 }
555
556 if (PrintMIR)
557 addPass(PrintMIRPass(Out), /*Force=*/true);
558
559 return verifyStartStop(*StartStopInfo);
560}
561
562template <typename Derived, typename TargetMachineT>
565 if (!Info.StartPass.empty()) {
566 Started = false;
567 BeforeCallbacks.emplace_back([this, &Info, AfterFlag = Info.StartAfter,
568 Count = 0u](StringRef ClassName) mutable {
569 if (Count == Info.StartInstanceNum) {
570 if (AfterFlag) {
571 AfterFlag = false;
572 Started = true;
573 }
574 return Started;
575 }
576
577 auto PassName = PIC->getPassNameForClassName(ClassName);
578 if (Info.StartPass == PassName && ++Count == Info.StartInstanceNum)
579 Started = !Info.StartAfter;
580
581 return Started;
582 });
583 }
584
585 if (!Info.StopPass.empty()) {
586 Stopped = false;
587 BeforeCallbacks.emplace_back([this, &Info, AfterFlag = Info.StopAfter,
588 Count = 0u](StringRef ClassName) mutable {
589 if (Count == Info.StopInstanceNum) {
590 if (AfterFlag) {
591 AfterFlag = false;
592 Stopped = true;
593 }
594 return !Stopped;
595 }
596
597 auto PassName = PIC->getPassNameForClassName(ClassName);
598 if (Info.StopPass == PassName && ++Count == Info.StopInstanceNum)
599 Stopped = !Info.StopAfter;
600 return !Stopped;
601 });
602 }
603}
604
605template <typename Derived, typename TargetMachineT>
606Error CodeGenPassBuilder<Derived, TargetMachineT>::verifyStartStop(
607 const TargetPassConfig::StartStopInfo &Info) const {
608 if (Started && Stopped)
609 return Error::success();
610
611 if (!Started)
612 return make_error<StringError>(
613 "Can't find start pass \"" + Info.StartPass + "\".",
614 std::make_error_code(std::errc::invalid_argument));
615 if (!Stopped)
616 return make_error<StringError>(
617 "Can't find stop pass \"" + Info.StopPass + "\".",
618 std::make_error_code(std::errc::invalid_argument));
619 return Error::success();
620}
621
622template <typename Derived, typename TargetMachineT>
624 AddIRPass &addPass) const {
625 derived().addGlobalMergePass(addPass);
626 if (TM.useEmulatedTLS())
627 addPass(LowerEmuTLSPass());
628
630
631 derived().addIRPasses(addPass);
632 derived().addCodeGenPrepare(addPass);
633 addPassesToHandleExceptions(addPass);
634 derived().addISelPrepare(addPass);
635}
636
637/// Add common target configurable passes that perform LLVM IR to IR transforms
638/// following machine independent optimization.
639template <typename Derived, typename TargetMachineT>
641 AddIRPass &addPass) const {
642 // Before running any passes, run the verifier to determine if the input
643 // coming from the front-end and/or optimizer is valid.
644 if (!Opt.DisableVerify)
645 addPass(VerifierPass());
646
647 // Run loop strength reduction before anything else.
648 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableLSR) {
650 /*UseMemorySSA=*/true));
651 // FIXME: use -stop-after so we could remove PrintLSR
652 if (Opt.PrintLSR)
653 addPass(PrintFunctionPass(dbgs(), "\n\n*** Code after LSR ***\n"));
654 }
655
656 if (getOptLevel() != CodeGenOptLevel::None) {
657 // The MergeICmpsPass tries to create memcmp calls by grouping sequences of
658 // loads and compares. ExpandMemCmpPass then tries to expand those calls
659 // into optimally-sized loads and compares. The transforms are enabled by a
660 // target lowering hook.
661 if (!Opt.DisableMergeICmps)
662 addPass(MergeICmpsPass());
663 addPass(ExpandMemCmpPass(&TM));
664 }
665
666 // Run GC lowering passes for builtin collectors
667 // TODO: add a pass insertion point here
668 addPass(GCLoweringPass());
669 addPass(ShadowStackGCLoweringPass());
671
672 // Make sure that no unreachable blocks are instruction selected.
673 addPass(UnreachableBlockElimPass());
674
675 // Prepare expensive constants for SelectionDAG.
676 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableConstantHoisting)
677 addPass(ConstantHoistingPass());
678
679 // Replace calls to LLVM intrinsics (e.g., exp, log) operating on vector
680 // operands with calls to the corresponding functions in a vector library.
681 if (getOptLevel() != CodeGenOptLevel::None)
682 addPass(ReplaceWithVeclib());
683
684 if (getOptLevel() != CodeGenOptLevel::None &&
687
688 // Instrument function entry and exit, e.g. with calls to mcount().
689 addPass(EntryExitInstrumenterPass(/*PostInlining=*/true));
690
691 // Add scalarization of target's unsupported masked memory intrinsics pass.
692 // the unsupported intrinsic will be replaced with a chain of basic blocks,
693 // that stores/loads element one-by-one if the appropriate mask bit is set.
695
696 // Expand reduction intrinsics into shuffle sequences if the target wants to.
697 addPass(ExpandReductionsPass());
698
699 // Convert conditional moves to conditional jumps when profitable.
700 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableSelectOptimize)
701 addPass(SelectOptimizePass(&TM));
702}
703
704/// Turn exception handling constructs into something the code generators can
705/// handle.
706template <typename Derived, typename TargetMachineT>
708 AddIRPass &addPass) const {
709 const MCAsmInfo *MCAI = TM.getMCAsmInfo();
710 assert(MCAI && "No MCAsmInfo");
711 switch (MCAI->getExceptionHandlingType()) {
712 case ExceptionHandling::SjLj:
713 // SjLj piggy-backs on dwarf for this bit. The cleanups done apply to both
714 // Dwarf EH prepare needs to be run after SjLj prepare. Otherwise,
715 // catch info can get misplaced when a selector ends up more than one block
716 // removed from the parent invoke(s). This could happen when a landing
717 // pad is shared by multiple invokes and is also a target of a normal
718 // edge from elsewhere.
719 addPass(SjLjEHPreparePass(&TM));
720 [[fallthrough]];
721 case ExceptionHandling::DwarfCFI:
722 case ExceptionHandling::ARM:
723 case ExceptionHandling::AIX:
724 case ExceptionHandling::ZOS:
725 addPass(DwarfEHPreparePass(&TM));
726 break;
727 case ExceptionHandling::WinEH:
728 // We support using both GCC-style and MSVC-style exceptions on Windows, so
729 // add both preparation passes. Each pass will only actually run if it
730 // recognizes the personality function.
731 addPass(WinEHPreparePass());
732 addPass(DwarfEHPreparePass(&TM));
733 break;
734 case ExceptionHandling::Wasm:
735 // Wasm EH uses Windows EH instructions, but it does not need to demote PHIs
736 // on catchpads and cleanuppads because it does not outline them into
737 // funclets. Catchswitch blocks are not lowered in SelectionDAG, so we
738 // should remove PHIs there.
739 addPass(WinEHPreparePass(/*DemoteCatchSwitchPHIOnly=*/false));
740 addPass(WasmEHPreparePass());
741 break;
742 case ExceptionHandling::None:
743 addPass(LowerInvokePass());
744
745 // The lower invoke pass may create unreachable code. Remove it.
746 addPass(UnreachableBlockElimPass());
747 break;
748 }
749}
750
751/// Add pass to prepare the LLVM IR for code generation. This should be done
752/// before exception handling preparation passes.
753template <typename Derived, typename TargetMachineT>
755 AddIRPass &addPass) const {
756 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableCGP)
757 addPass(CodeGenPreparePass(&TM));
758 // TODO: Default ctor'd RewriteSymbolPass is no-op.
759 // addPass(RewriteSymbolPass());
760}
761
762/// Add common passes that perform LLVM IR to IR transforms in preparation for
763/// instruction selection.
764template <typename Derived, typename TargetMachineT>
766 AddIRPass &addPass) const {
767 derived().addPreISel(addPass);
768
769 addPass(CallBrPreparePass());
770 // Add both the safe stack and the stack protection passes: each of them will
771 // only protect functions that have corresponding attributes.
772 addPass(SafeStackPass(&TM));
773 addPass(StackProtectorPass(&TM));
774
775 if (Opt.PrintISelInput)
776 addPass(PrintFunctionPass(dbgs(),
777 "\n\n*** Final LLVM Code input to ISel ***\n"));
778
779 // All passes which modify the LLVM IR are now complete; run the verifier
780 // to ensure that the IR is valid.
781 if (!Opt.DisableVerify)
782 addPass(VerifierPass());
783}
784
785template <typename Derived, typename TargetMachineT>
787 AddMachinePass &addPass) const {
788 // Enable FastISel with -fast-isel, but allow that to be overridden.
789 TM.setO0WantsFastISel(Opt.EnableFastISelOption.value_or(true));
790
791 // Determine an instruction selector.
792 enum class SelectorType { SelectionDAG, FastISel, GlobalISel };
793 SelectorType Selector;
794
795 if (Opt.EnableFastISelOption && *Opt.EnableFastISelOption == true)
796 Selector = SelectorType::FastISel;
797 else if ((Opt.EnableGlobalISelOption &&
798 *Opt.EnableGlobalISelOption == true) ||
799 (TM.Options.EnableGlobalISel &&
801 *Opt.EnableGlobalISelOption == false)))
802 Selector = SelectorType::GlobalISel;
803 else if (TM.getOptLevel() == CodeGenOptLevel::None && TM.getO0WantsFastISel())
804 Selector = SelectorType::FastISel;
805 else
806 Selector = SelectorType::SelectionDAG;
807
808 // Set consistently TM.Options.EnableFastISel and EnableGlobalISel.
809 if (Selector == SelectorType::FastISel) {
810 TM.setFastISel(true);
811 TM.setGlobalISel(false);
812 } else if (Selector == SelectorType::GlobalISel) {
813 TM.setFastISel(false);
814 TM.setGlobalISel(true);
815 }
816
817 // Add instruction selector passes.
818 if (Selector == SelectorType::GlobalISel) {
819 if (auto Err = derived().addIRTranslator(addPass))
820 return std::move(Err);
821
822 derived().addPreLegalizeMachineIR(addPass);
823
824 if (auto Err = derived().addLegalizeMachineIR(addPass))
825 return std::move(Err);
826
827 // Before running the register bank selector, ask the target if it
828 // wants to run some passes.
829 derived().addPreRegBankSelect(addPass);
830
831 if (auto Err = derived().addRegBankSelect(addPass))
832 return std::move(Err);
833
834 derived().addPreGlobalInstructionSelect(addPass);
835
836 if (auto Err = derived().addGlobalInstructionSelect(addPass))
837 return std::move(Err);
838
839 // Pass to reset the MachineFunction if the ISel failed.
840 addPass(ResetMachineFunctionPass(reportDiagnosticWhenGlobalISelFallback(),
841 isGlobalISelAbortEnabled()));
842
843 // Provide a fallback path when we do not want to abort on
844 // not-yet-supported input.
845 if (!isGlobalISelAbortEnabled())
846 if (auto Err = derived().addInstSelector(addPass))
847 return std::move(Err);
848
849 } else if (auto Err = derived().addInstSelector(addPass))
850 return std::move(Err);
851
852 // Expand pseudo-instructions emitted by ISel. Don't run the verifier before
853 // FinalizeISel.
854 addPass(FinalizeISelPass());
855
856 // // Print the instruction selected machine code...
857 // printAndVerify("After Instruction Selection");
858
859 return Error::success();
860}
861
862/// Add the complete set of target-independent postISel code generator passes.
863///
864/// This can be read as the standard order of major LLVM CodeGen stages. Stages
865/// with nontrivial configuration or multiple passes are broken out below in
866/// add%Stage routines.
867///
868/// Any CodeGenPassBuilder<Derived, TargetMachine>::addXX routine may be
869/// overriden by the Target. The addPre/Post methods with empty header
870/// implementations allow injecting target-specific fixups just before or after
871/// major stages. Additionally, targets have the flexibility to change pass
872/// order within a stage by overriding default implementation of add%Stage
873/// routines below. Each technique has maintainability tradeoffs because
874/// alternate pass orders are not well supported. addPre/Post works better if
875/// the target pass is easily tied to a common pass. But if it has subtle
876/// dependencies on multiple passes, the target should override the stage
877/// instead.
878template <typename Derived, typename TargetMachineT>
880 AddMachinePass &addPass) const {
881 // Add passes that optimize machine instructions in SSA form.
882 if (getOptLevel() != CodeGenOptLevel::None) {
883 derived().addMachineSSAOptimization(addPass);
884 } else {
885 // If the target requests it, assign local variables to stack slots relative
886 // to one another and simplify frame index references where possible.
888 }
889
890 if (TM.Options.EnableIPRA)
891 addPass(RegUsageInfoPropagationPass());
892
893 // Run pre-ra passes.
894 derived().addPreRegAlloc(addPass);
895
896 // Run register allocation and passes that are tightly coupled with it,
897 // including phi elimination and scheduling.
898 if (*Opt.OptimizeRegAlloc) {
899 derived().addOptimizedRegAlloc(addPass);
900 } else {
901 if (auto Err = derived().addFastRegAlloc(addPass))
902 return Err;
903 }
904
905 // Run post-ra passes.
906 derived().addPostRegAlloc(addPass);
907
908 addPass(RemoveRedundantDebugValuesPass());
909
910 // Insert prolog/epilog code. Eliminate abstract frame index references...
911 if (getOptLevel() != CodeGenOptLevel::None) {
912 addPass(PostRAMachineSinkingPass());
913 addPass(ShrinkWrapPass());
914 }
915
916 addPass(PrologEpilogInserterPass());
917
918 /// Add passes that optimize machine instructions after register allocation.
919 if (getOptLevel() != CodeGenOptLevel::None)
920 derived().addMachineLateOptimization(addPass);
921
922 // Expand pseudo instructions before second scheduling pass.
923 addPass(ExpandPostRAPseudosPass());
924
925 // Run pre-sched2 passes.
926 derived().addPreSched2(addPass);
927
929 addPass(ImplicitNullChecksPass());
930
931 // Second pass scheduler.
932 // Let Target optionally insert this pass by itself at some other
933 // point.
934 if (getOptLevel() != CodeGenOptLevel::None &&
935 !TM.targetSchedulesPostRAScheduling()) {
936 if (Opt.MISchedPostRA)
937 addPass(PostMachineSchedulerPass());
938 else
939 addPass(PostRASchedulerPass());
940 }
941
942 // GC
943 derived().addGCPasses(addPass);
944
945 // Basic block placement.
946 if (getOptLevel() != CodeGenOptLevel::None)
947 derived().addBlockPlacement(addPass);
948
949 // Insert before XRay Instrumentation.
950 addPass(FEntryInserterPass());
951
952 addPass(XRayInstrumentationPass());
953 addPass(PatchableFunctionPass());
954
955 derived().addPreEmitPass(addPass);
956
957 if (TM.Options.EnableIPRA)
958 // Collect register usage information and produce a register mask of
959 // clobbered registers, to be used to optimize call sites.
960 addPass(RegUsageInfoCollectorPass());
961
962 addPass(FuncletLayoutPass());
963
964 addPass(StackMapLivenessPass());
965 addPass(LiveDebugValuesPass());
966 addPass(MachineSanitizerBinaryMetadata());
967
968 if (TM.Options.EnableMachineOutliner &&
969 getOptLevel() != CodeGenOptLevel::None &&
970 Opt.EnableMachineOutliner != RunOutliner::NeverOutline) {
971 bool RunOnAllFunctions =
972 (Opt.EnableMachineOutliner == RunOutliner::AlwaysOutline);
973 bool AddOutliner = RunOnAllFunctions || TM.Options.SupportsDefaultOutlining;
974 if (AddOutliner)
975 addPass(MachineOutlinerPass(RunOnAllFunctions));
976 }
977
978 // Add passes that directly emit MI after all other MI passes.
979 derived().addPreEmitPass2(addPass);
980
981 return Error::success();
982}
983
984/// Add passes that optimize machine instructions in SSA form.
985template <typename Derived, typename TargetMachineT>
987 AddMachinePass &addPass) const {
988 // Pre-ra tail duplication.
989 addPass(EarlyTailDuplicatePass());
990
991 // Optimize PHIs before DCE: removing dead PHI cycles may make more
992 // instructions dead.
993 addPass(OptimizePHIsPass());
994
995 // This pass merges large allocas. StackSlotColoring is a different pass
996 // which merges spill slots.
997 addPass(StackColoringPass());
998
999 // If the target requests it, assign local variables to stack slots relative
1000 // to one another and simplify frame index references where possible.
1002
1003 // With optimization, dead code should already be eliminated. However
1004 // there is one known exception: lowered code for arguments that are only
1005 // used by tail calls, where the tail calls reuse the incoming stack
1006 // arguments directly (see t11 in test/CodeGen/X86/sibcall.ll).
1008
1009 // Allow targets to insert passes that improve instruction level parallelism,
1010 // like if-conversion. Such passes will typically need dominator trees and
1011 // loop info, just like LICM and CSE below.
1012 derived().addILPOpts(addPass);
1013
1014 addPass(EarlyMachineLICMPass());
1015 addPass(MachineCSEPass());
1016
1017 addPass(MachineSinkingPass());
1018
1019 addPass(PeepholeOptimizerPass());
1020 // Clean-up the dead code that may have been generated by peephole
1021 // rewriting.
1023}
1024
1025//===---------------------------------------------------------------------===//
1026/// Register Allocation Pass Configuration
1027//===---------------------------------------------------------------------===//
1028
1029/// Instantiate the default register allocator pass for this target for either
1030/// the optimized or unoptimized allocation path. This will be added to the pass
1031/// manager by addFastRegAlloc in the unoptimized case or addOptimizedRegAlloc
1032/// in the optimized case.
1033///
1034/// A target that uses the standard regalloc pass order for fast or optimized
1035/// allocation may still override this for per-target regalloc
1036/// selection. But -regalloc=... always takes precedence.
1037template <typename Derived, typename TargetMachineT>
1039 AddMachinePass &addPass, bool Optimized) const {
1040 if (Optimized)
1041 addPass(RAGreedyPass());
1042 else
1043 addPass(RegAllocFastPass());
1044}
1045
1046/// Find and instantiate the register allocation pass requested by this target
1047/// at the current optimization level. Different register allocators are
1048/// defined as separate passes because they may require different analysis.
1049template <typename Derived, typename TargetMachineT>
1051 AddMachinePass &addPass, bool Optimized) const {
1052 // TODO: Parse Opt.RegAlloc to add register allocator.
1053}
1054
1055template <typename Derived, typename TargetMachineT>
1057 AddMachinePass &addPass) const {
1058 // TODO: Ensure allocator is default or fast.
1059 addRegAllocPass(addPass, false);
1060 return Error::success();
1061}
1062
1063template <typename Derived, typename TargetMachineT>
1065 AddMachinePass &addPass) const {
1066 // Add the selected register allocation pass.
1067 addRegAllocPass(addPass, true);
1068
1069 // Allow targets to change the register assignments before rewriting.
1070 derived().addPreRewrite(addPass);
1071
1072 // Finally rewrite virtual registers.
1073 addPass(VirtRegRewriterPass());
1074 // Perform stack slot coloring and post-ra machine LICM.
1075 //
1076 // FIXME: Re-enable coloring with register when it's capable of adding
1077 // kill markers.
1078 addPass(StackSlotColoringPass());
1079
1080 return Error::success();
1081}
1082
1083/// Add the minimum set of target-independent passes that are required for
1084/// register allocation. No coalescing or scheduling.
1085template <typename Derived, typename TargetMachineT>
1087 AddMachinePass &addPass) const {
1088 addPass(PHIEliminationPass());
1089 addPass(TwoAddressInstructionPass());
1090 return derived().addRegAssignmentFast(addPass);
1091}
1092
1093/// Add standard target-independent passes that are tightly coupled with
1094/// optimized register allocation, including coalescing, machine instruction
1095/// scheduling, and register allocation itself.
1096template <typename Derived, typename TargetMachineT>
1098 AddMachinePass &addPass) const {
1099 addPass(DetectDeadLanesPass());
1100
1101 addPass(InitUndefPass());
1102
1103 addPass(ProcessImplicitDefsPass());
1104
1105 // Edge splitting is smarter with machine loop info.
1106 addPass(PHIEliminationPass());
1107
1108 // Eventually, we want to run LiveIntervals before PHI elimination.
1109 if (Opt.EarlyLiveIntervals)
1111
1112 addPass(TwoAddressInstructionPass());
1113 addPass(RegisterCoalescerPass());
1114
1115 // The machine scheduler may accidentally create disconnected components
1116 // when moving subregister definitions around, avoid this by splitting them to
1117 // separate vregs before. Splitting can also improve reg. allocation quality.
1118 addPass(RenameIndependentSubregsPass());
1119
1120 // PreRA instruction scheduling.
1121 addPass(MachineSchedulerPass());
1122
1123 if (derived().addRegAssignmentOptimized(addPass)) {
1124 // Allow targets to expand pseudo instructions depending on the choice of
1125 // registers before MachineCopyPropagation.
1126 derived().addPostRewrite(addPass);
1127
1128 // Copy propagate to forward register uses and try to eliminate COPYs that
1129 // were not coalesced.
1130 addPass(MachineCopyPropagationPass());
1131
1132 // Run post-ra machine LICM to hoist reloads / remats.
1133 //
1134 // FIXME: can this move into MachineLateOptimization?
1135 addPass(MachineLICMPass());
1136 }
1137}
1138
1139//===---------------------------------------------------------------------===//
1140/// Post RegAlloc Pass Configuration
1141//===---------------------------------------------------------------------===//
1142
1143/// Add passes that optimize machine instructions after register allocation.
1144template <typename Derived, typename TargetMachineT>
1146 AddMachinePass &addPass) const {
1147 // Branch folding must be run after regalloc and prolog/epilog insertion.
1148 addPass(BranchFolderPass());
1149
1150 // Tail duplication.
1151 // Note that duplicating tail just increases code size and degrades
1152 // performance for targets that require Structured Control Flow.
1153 // In addition it can also make CFG irreducible. Thus we disable it.
1154 if (!TM.requiresStructuredCFG())
1155 addPass(TailDuplicatePass());
1156
1157 // Cleanup of redundant (identical) address/immediate loads.
1158 addPass(MachineLateInstrsCleanupPass());
1159
1160 // Copy propagation.
1161 addPass(MachineCopyPropagationPass());
1162}
1163
1164/// Add standard basic block placement passes.
1165template <typename Derived, typename TargetMachineT>
1167 AddMachinePass &addPass) const {
1168 addPass(MachineBlockPlacementPass());
1169 // Run a separate pass to collect block placement statistics.
1171 addPass(MachineBlockPlacementStatsPass());
1172}
1173
1174} // namespace llvm
1175
1176#endif // LLVM_PASSES_CODEGENPASSBUILDER_H
This is the interface for LLVM's primary stateless and local alias analysis.
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
Defines an IR pass for CodeGen Prepare.
std::string Name
This file defines passes to print out IR in various granularities.
This file contains the declaration of the InterleavedAccessPass class, its corresponding pass name is...
This header provides classes for managing a pipeline of passes over loops in LLVM IR.
The header file for the LowerConstantIntrinsics pass as used by the new pass manager.
if(VerifyEach)
ModulePassManager MPM
const char LLVMTargetMachineRef TM
PassInstrumentationCallbacks PIC
PassBuilder PB(Machine, PassOpts->PTO, std::nullopt, &PIC)
This header defines various interfaces for pass management in LLVM.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This is the interface for a metadata-based scoped no-alias analysis.
This file contains the declaration of the SelectOptimizePass class, its corresponding pass name is se...
This file defines the SmallVector class.
Target-Independent Code Generator Pass Configuration Options pass.
This pass exposes codegen information to IR-level passes.
This is the interface for a metadata-based TBAA.
static const char PassName[]
AddIRPass(ModulePassManager &MPM, const DerivedT &PB)
void operator()(PassT &&Pass, StringRef Name=PassT::name())
AddMachinePass(ModulePassManager &MPM, const DerivedT &PB)
void operator()(PassT &&Pass, bool Force=false, StringRef Name=PassT::name())
This class provides access to building LLVM's passes.
void addPreRewrite(AddMachinePass &) const
addPreRewrite - Add passes to the optimized register allocation pipeline after register allocation is...
void addPostRegAlloc(AddMachinePass &) const
This method may be implemented by targets that want to run passes after register allocation pass pipe...
void insertPass(InsertedPassT &&Pass)
Insert InsertedPass pass after TargetPass pass.
void addPreGlobalInstructionSelect(AddMachinePass &) const
This method may be implemented by targets that want to run passes immediately before the (global) ins...
Error addRegAssignmentFast(AddMachinePass &) const
Add core register alloator passes which do the actual register assignment and rewriting.
Error addFastRegAlloc(AddMachinePass &) const
addFastRegAlloc - Add the minimum set of target-independent passes that are required for fast registe...
Error addIRTranslator(AddMachinePass &) const
This method should install an IR translator pass, which converts from LLVM code to machine instructio...
void addILPOpts(AddMachinePass &) const
Add passes that optimize instruction level parallelism for out-of-order targets.
void addRegAllocPass(AddMachinePass &, bool Optimized) const
addMachinePasses helper to create the target-selected or overriden regalloc pass.
void addPreSched2(AddMachinePass &) const
This method may be implemented by targets that want to run passes after prolog-epilog insertion and b...
std::function< Expected< std::unique_ptr< MCStreamer > >(MCContext &)> CreateMCStreamer
Error addRegBankSelect(AddMachinePass &) const
This method should install a register bank selector pass, which assigns register banks to virtual reg...
decltype(std::declval< PassT & >().isRequired()) has_required_t
bool isGlobalISelAbortEnabled() const
Check whether or not GlobalISel should abort on error.
void addPreRegAlloc(AddMachinePass &) const
This method may be implemented by targets that want to run passes immediately before register allocat...
void addGCPasses(AddMachinePass &) const
addGCPasses - Add late codegen passes that analyze code for garbage collection.
Error buildPipeline(ModulePassManager &MPM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType) const
void addGlobalMergePass(AddIRPass &) const
Target can override this to add GlobalMergePass before all IR passes.
Error addLegalizeMachineIR(AddMachinePass &) const
This method should install a legalize pass, which converts the instruction sequence into one that can...
Error addCoreISelPasses(AddMachinePass &) const
Add the actual instruction selection passes.
void addOptimizedRegAlloc(AddMachinePass &) const
addOptimizedRegAlloc - Add passes related to register allocation.
void addISelPasses(AddIRPass &) const
High level function that adds all passes necessary to go from llvm IR representation to the MI repres...
PassInstrumentationCallbacks * PIC
void addMachineSSAOptimization(AddMachinePass &) const
Methods with trivial inline returns are convenient points in the common codegen pass pipeline where t...
decltype(std::declval< PassT & >().run(std::declval< Module & >(), std::declval< ModuleAnalysisManager & >())) is_module_pass_t
CodeGenPassBuilder(TargetMachineT &TM, const CGPassBuilderOption &Opts, PassInstrumentationCallbacks *PIC)
Error addRegAssignmentOptimized(AddMachinePass &) const
void addCodeGenPrepare(AddIRPass &) const
Add pass to prepare the LLVM IR for code generation.
Error addMachinePasses(AddMachinePass &) const
Add the complete, standard set of LLVM CodeGen passes.
void addISelPrepare(AddIRPass &) const
Add common passes that perform LLVM IR to IR transforms in preparation for instruction selection.
void disablePass()
Allow the target to disable a specific pass by default.
void addBlockPlacement(AddMachinePass &) const
Add standard basic block placement passes.
Error addInstSelector(AddMachinePass &) const
addInstSelector - This method should install an instruction selector pass, which converts from LLVM c...
void addTargetRegisterAllocator(AddMachinePass &, bool Optimized) const
Utilities for targets to add passes to the pass manager.
void addPreEmitPass2(AddMachinePass &) const
Targets may add passes immediately before machine code is emitted in this callback.
void addPostRewrite(AddMachinePass &) const
Add passes to be run immediately after virtual registers are rewritten to physical registers.
void addPreRegBankSelect(AddMachinePass &) const
This method may be implemented by targets that want to run passes immediately before the register ban...
void addPreEmitPass(AddMachinePass &) const
This pass may be implemented by targets that want to run passes immediately before machine code is em...
Error addGlobalInstructionSelect(AddMachinePass &) const
This method should install a (global) instruction selector pass, which converts possibly generic inst...
void addMachineLateOptimization(AddMachinePass &) const
Add passes that optimize machine instructions after register allocation.
void addIRPasses(AddIRPass &) const
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
decltype(std::declval< PassT & >().run(std::declval< Function & >(), std::declval< FunctionAnalysisManager & >())) is_function_pass_t
decltype(std::declval< PassT & >().run(std::declval< MachineFunction & >(), std::declval< MachineFunctionAnalysisManager & >())) is_machine_function_pass_t
void addPreLegalizeMachineIR(AddMachinePass &) const
This method may be implemented by targets that want to run passes immediately before legalization.
CodeGenOptLevel getOptLevel() const
void addPassesToHandleExceptions(AddIRPass &) const
Add passes to lower exception handling for the code generator.
PassInstrumentationCallbacks * getPassInstrumentationCallbacks() const
bool reportDiagnosticWhenGlobalISelFallback() const
Check whether or not a diagnostic should be emitted when GlobalISel uses the fallback path.
void addPreISel(AddIRPass &) const
{{@ For GlobalISel
void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
Definition: FastISel.h:66
LowerIntrinsics - This pass rewrites calls to the llvm.gcread or llvm.gcwrite intrinsics,...
Definition: GCMetadata.h:195
Performs Loop Strength Reduce Pass.
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
ExceptionHandling getExceptionHandlingType() const
Definition: MCAsmInfo.h:774
Context object for machine code objects.
Definition: MCContext.h:83
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
StringRef getPassNameForClassName(StringRef ClassName)
Get the pass name for a given pass class name.
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!std::is_same_v< PassT, PassManager > > addPass(PassT &&Pass)
Definition: PassManager.h:195
bool isEmpty() const
Returns if the pass manager contains any passes.
Definition: PassManager.h:217
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:94
Pass (for the new pass manager) for printing a Function as LLVM's text IR assembly.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:228
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
static Expected< StartStopInfo > getStartStopInfo(PassInstrumentationCallbacks &PIC)
Returns pass name in -stop-before or -stop-after NOTE: New pass manager migration only.
static bool willCompleteCodeGenPipeline()
Returns true if none of the -stop-before and -stop-after options is set.
Create a verifier pass.
Definition: Verifier.h:132
An abstract base class for streams implementations that also support a pwrite operation.
Definition: raw_ostream.h:434
unique_function is a type-erasing functor similar to std::function.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
PassManager< Function > FunctionPassManager
Convenience typedef for a pass manager over functions.
Definition: PassManager.h:246
ModuleToFunctionPassAdaptor createModuleToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
Definition: PassManager.h:848
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:98
PassManager< MachineFunction > MachineFunctionPassManager
Convenience typedef for a pass manager over functions.
typename detail::detector< void, Op, Args... >::value_t is_detected
Detects if a given trait holds for some set of arguments 'Args'.
Definition: STLExtras.h:79
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
Definition: CodeGen.h:83
FunctionToMachineFunctionPassAdaptor createFunctionToMachineFunctionPassAdaptor(MachineFunctionPassT &&Pass)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
CodeGenOptLevel
Code generation optimization level.
Definition: CodeGen.h:54
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
Definition: SmallVector.h:1136
std::enable_if_t< is_detected< HasRunOnLoopT, LoopPassT >::value, FunctionToLoopPassAdaptor > createFunctionToLoopPassAdaptor(LoopPassT &&Pass, bool UseMemorySSA=false, bool UseBlockFrequencyInfo=false, bool UseBranchProbabilityInfo=false)
A function to deduce a loop pass type and wrap it in the templated adaptor.
std::optional< bool > EnableGlobalISelOption
std::optional< bool > EnableIPRA
std::optional< bool > OptimizeRegAlloc
std::optional< bool > EnableFastISelOption
std::optional< GlobalISelAbortMode > EnableGlobalISelAbort
A no-op pass template which simply forces a specific analysis result to be invalidated.
Definition: PassManager.h:901
A utility pass template to force an analysis result to be available.
Definition: PassManager.h:874