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