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