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