LLVM 18.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 registering analysis passes, producing common pass manager
11/// configurations, and parsing of pass pipelines.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CODEGEN_CODEGENPASSBUILDER_H
16#define LLVM_CODEGEN_CODEGENPASSBUILDER_H
17
19#include "llvm/ADT/StringRef.h"
30#include "llvm/IR/PassManager.h"
31#include "llvm/IR/Verifier.h"
33#include "llvm/MC/MCAsmInfo.h"
36#include "llvm/Support/Debug.h"
37#include "llvm/Support/Error.h"
50#include <cassert>
51#include <type_traits>
52#include <utility>
53
54namespace llvm {
55
56// FIXME: Dummy target independent passes definitions that have not yet been
57// ported to new pass manager. Once they do, remove these.
58#define DUMMY_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
59 struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
60 template <typename... Ts> PASS_NAME(Ts &&...) {} \
61 PreservedAnalyses run(Function &, FunctionAnalysisManager &) { \
62 return PreservedAnalyses::all(); \
63 } \
64 };
65#define DUMMY_MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
66 struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
67 template <typename... Ts> PASS_NAME(Ts &&...) {} \
68 PreservedAnalyses run(Module &, ModuleAnalysisManager &) { \
69 return PreservedAnalyses::all(); \
70 } \
71 };
72#define DUMMY_MACHINE_MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
73 struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
74 template <typename... Ts> PASS_NAME(Ts &&...) {} \
75 Error run(Module &, MachineFunctionAnalysisManager &) { \
76 return Error::success(); \
77 } \
78 PreservedAnalyses run(MachineFunction &, \
79 MachineFunctionAnalysisManager &) { \
80 llvm_unreachable("this api is to make new PM api happy"); \
81 } \
82 static AnalysisKey Key; \
83 };
84#define DUMMY_MACHINE_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
85 struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
86 template <typename... Ts> PASS_NAME(Ts &&...) {} \
87 PreservedAnalyses run(MachineFunction &, \
88 MachineFunctionAnalysisManager &) { \
89 return PreservedAnalyses::all(); \
90 } \
91 static AnalysisKey Key; \
92 };
93#include "MachinePassRegistry.def"
94
95/// This class provides access to building LLVM's passes.
96///
97/// Its members provide the baseline state available to passes during their
98/// construction. The \c MachinePassRegistry.def file specifies how to construct
99/// all of the built-in passes, and those may reference these members during
100/// construction.
101template <typename DerivedT> class CodeGenPassBuilder {
102public:
105 : TM(TM), Opt(Opts), PIC(PIC) {
106 // Target could set CGPassBuilderOption::MISchedPostRA to true to achieve
107 // substitutePass(&PostRASchedulerID, &PostMachineSchedulerID)
108
109 // Target should override TM.Options.EnableIPRA in their target-specific
110 // LLVMTM ctor. See TargetMachine::setGlobalISel for example.
111 if (Opt.EnableIPRA)
113
116
119 }
120
123 CodeGenFileType FileType) const;
124
128 std::pair<StringRef, bool> getPassNameFromLegacyName(StringRef) const;
129
134 }
135
137 return PIC;
138 }
139
140protected:
141 template <typename PassT> using has_key_t = decltype(PassT::Key);
142
143 template <typename PassT>
144 using is_module_pass_t = decltype(std::declval<PassT &>().run(
145 std::declval<Module &>(), std::declval<ModuleAnalysisManager &>()));
146
147 template <typename PassT>
148 using is_function_pass_t = decltype(std::declval<PassT &>().run(
149 std::declval<Function &>(), std::declval<FunctionAnalysisManager &>()));
150
151 // Function object to maintain state while adding codegen IR passes.
152 class AddIRPass {
153 public:
154 AddIRPass(ModulePassManager &MPM, bool DebugPM, bool Check = true)
155 : MPM(MPM) {
156 if (Check)
157 AddingFunctionPasses = false;
158 }
160 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
161 }
162
163 // Add Function Pass
164 template <typename PassT>
165 std::enable_if_t<is_detected<is_function_pass_t, PassT>::value>
166 operator()(PassT &&Pass) {
167 if (AddingFunctionPasses && !*AddingFunctionPasses)
168 AddingFunctionPasses = true;
169 FPM.addPass(std::forward<PassT>(Pass));
170 }
171
172 // Add Module Pass
173 template <typename PassT>
174 std::enable_if_t<is_detected<is_module_pass_t, PassT>::value &&
176 operator()(PassT &&Pass) {
177 assert((!AddingFunctionPasses || !*AddingFunctionPasses) &&
178 "could not add module pass after adding function pass");
179 MPM.addPass(std::forward<PassT>(Pass));
180 }
181
182 private:
185 // The codegen IR pipeline are mostly function passes with the exceptions of
186 // a few loop and module passes. `AddingFunctionPasses` make sures that
187 // we could only add module passes at the beginning of the pipeline. Once
188 // we begin adding function passes, we could no longer add module passes.
189 // This special-casing introduces less adaptor passes. If we have the need
190 // of adding module passes after function passes, we could change the
191 // implementation to accommodate that.
192 std::optional<bool> AddingFunctionPasses;
193 };
194
195 // Function object to maintain state while adding codegen machine passes.
197 public:
199
200 template <typename PassT> void operator()(PassT &&Pass) {
201 static_assert(
203 "Machine function pass must define a static member variable `Key`.");
204 for (auto &C : BeforeCallbacks)
205 if (!C(&PassT::Key))
206 return;
207 PM.addPass(std::forward<PassT>(Pass));
208 for (auto &C : AfterCallbacks)
209 C(&PassT::Key);
210 }
211
212 template <typename PassT> void insertPass(AnalysisKey *ID, PassT Pass) {
213 AfterCallbacks.emplace_back(
214 [this, ID, Pass = std::move(Pass)](AnalysisKey *PassID) {
215 if (PassID == ID)
216 this->PM.addPass(std::move(Pass));
217 });
218 }
219
221 BeforeCallbacks.emplace_back(
222 [ID](AnalysisKey *PassID) { return PassID != ID; });
223 }
224
225 MachineFunctionPassManager releasePM() { return std::move(PM); }
226
227 private:
229 SmallVector<llvm::unique_function<bool(AnalysisKey *)>, 4> BeforeCallbacks;
230 SmallVector<llvm::unique_function<void(AnalysisKey *)>, 4> AfterCallbacks;
231 };
232
236
237 /// Target override these hooks to parse target-specific analyses.
241 std::pair<StringRef, bool> getTargetPassNameFromLegacyName(StringRef) const {
242 return {"", false};
243 }
244
245 template <typename TMC> TMC &getTM() const { return static_cast<TMC &>(TM); }
247
248 /// Check whether or not GlobalISel should abort on error.
249 /// When this is disabled, GlobalISel will fall back on SDISel instead of
250 /// erroring out.
253 }
254
255 /// Check whether or not a diagnostic should be emitted when GlobalISel
256 /// uses the fallback path. In other words, it will emit a diagnostic
257 /// when GlobalISel failed and isGlobalISelAbortEnabled is false.
260 }
261
262 /// addInstSelector - This method should install an instruction selector pass,
263 /// which converts from LLVM code to machine instructions.
265 return make_error<StringError>("addInstSelector is not overridden",
267 }
268
269 /// Add passes that optimize instruction level parallelism for out-of-order
270 /// targets. These passes are run while the machine code is still in SSA
271 /// form, so they can use MachineTraceMetrics to control their heuristics.
272 ///
273 /// All passes added here should preserve the MachineDominatorTree,
274 /// MachineLoopInfo, and MachineTraceMetrics analyses.
275 void addILPOpts(AddMachinePass &) const {}
276
277 /// This method may be implemented by targets that want to run passes
278 /// immediately before register allocation.
280
281 /// addPreRewrite - Add passes to the optimized register allocation pipeline
282 /// after register allocation is complete, but before virtual registers are
283 /// rewritten to physical registers.
284 ///
285 /// These passes must preserve VirtRegMap and LiveIntervals, and when running
286 /// after RABasic or RAGreedy, they should take advantage of LiveRegMatrix.
287 /// When these passes run, VirtRegMap contains legal physreg assignments for
288 /// all virtual registers.
289 ///
290 /// Note if the target overloads addRegAssignAndRewriteOptimized, this may not
291 /// be honored. This is also not generally used for the fast variant,
292 /// where the allocation and rewriting are done in one pass.
294
295 /// Add passes to be run immediately after virtual registers are rewritten
296 /// to physical registers.
298
299 /// This method may be implemented by targets that want to run passes after
300 /// register allocation pass pipeline but before prolog-epilog insertion.
302
303 /// This method may be implemented by targets that want to run passes after
304 /// prolog-epilog insertion and before the second instruction scheduling pass.
306
307 /// This pass may be implemented by targets that want to run passes
308 /// immediately before machine code is emitted.
310
311 /// Targets may add passes immediately before machine code is emitted in this
312 /// callback. This is called even later than `addPreEmitPass`.
313 // FIXME: Rename `addPreEmitPass` to something more sensible given its actual
314 // position and remove the `2` suffix here as this callback is what
315 // `addPreEmitPass` *should* be but in reality isn't.
317
318 /// {{@ For GlobalISel
319 ///
320
321 /// addPreISel - This method should add any "last minute" LLVM->LLVM
322 /// passes (which are run just before instruction selector).
323 void addPreISel(AddIRPass &) const {
324 llvm_unreachable("addPreISel is not overridden");
325 }
326
327 /// This method should install an IR translator pass, which converts from
328 /// LLVM code to machine instructions with possibly generic opcodes.
330 return make_error<StringError>("addIRTranslator is not overridden",
332 }
333
334 /// This method may be implemented by targets that want to run passes
335 /// immediately before legalization.
337
338 /// This method should install a legalize pass, which converts the instruction
339 /// sequence into one that can be selected by the target.
341 return make_error<StringError>("addLegalizeMachineIR is not overridden",
343 }
344
345 /// This method may be implemented by targets that want to run passes
346 /// immediately before the register bank selection.
348
349 /// This method should install a register bank selector pass, which
350 /// assigns register banks to virtual registers without a register
351 /// class or register banks.
353 return make_error<StringError>("addRegBankSelect is not overridden",
355 }
356
357 /// This method may be implemented by targets that want to run passes
358 /// immediately before the (global) instruction selection.
360
361 /// This method should install a (global) instruction selector pass, which
362 /// converts possibly generic instructions to fully target-specific
363 /// instructions, thereby constraining all generic virtual registers to
364 /// register classes.
366 return make_error<StringError>(
367 "addGlobalInstructionSelect is not overridden",
369 }
370 /// @}}
371
372 /// High level function that adds all passes necessary to go from llvm IR
373 /// representation to the MI representation.
374 /// Adds IR based lowering and target specific optimization passes and finally
375 /// the core instruction selection passes.
376 void addISelPasses(AddIRPass &) const;
377
378 /// Add the actual instruction selection passes. This does not include
379 /// preparation passes on IR.
380 Error addCoreISelPasses(AddMachinePass &) const;
381
382 /// Add the complete, standard set of LLVM CodeGen passes.
383 /// Fully developed targets will not generally override this.
384 Error addMachinePasses(AddMachinePass &) const;
385
386 /// Add passes to lower exception handling for the code generator.
387 void addPassesToHandleExceptions(AddIRPass &) const;
388
389 /// Add common target configurable passes that perform LLVM IR to IR
390 /// transforms following machine independent optimization.
391 void addIRPasses(AddIRPass &) const;
392
393 /// Add pass to prepare the LLVM IR for code generation. This should be done
394 /// before exception handling preparation passes.
395 void addCodeGenPrepare(AddIRPass &) const;
396
397 /// Add common passes that perform LLVM IR to IR transforms in preparation for
398 /// instruction selection.
399 void addISelPrepare(AddIRPass &) const;
400
401 /// Methods with trivial inline returns are convenient points in the common
402 /// codegen pass pipeline where targets may insert passes. Methods with
403 /// out-of-line standard implementations are major CodeGen stages called by
404 /// addMachinePasses. Some targets may override major stages when inserting
405 /// passes is insufficient, but maintaining overriden stages is more work.
406 ///
407
408 /// addMachineSSAOptimization - Add standard passes that optimize machine
409 /// instructions in SSA form.
410 void addMachineSSAOptimization(AddMachinePass &) const;
411
412 /// addFastRegAlloc - Add the minimum set of target-independent passes that
413 /// are required for fast register allocation.
414 Error addFastRegAlloc(AddMachinePass &) const;
415
416 /// addOptimizedRegAlloc - Add passes related to register allocation.
417 /// LLVMTargetMachine provides standard regalloc passes for most targets.
418 void addOptimizedRegAlloc(AddMachinePass &) const;
419
420 /// Add passes that optimize machine instructions after register allocation.
421 void addMachineLateOptimization(AddMachinePass &) const;
422
423 /// addGCPasses - Add late codegen passes that analyze code for garbage
424 /// collection. This should return true if GC info should be printed after
425 /// these passes.
427
428 /// Add standard basic block placement passes.
429 void addBlockPlacement(AddMachinePass &) const;
430
432 std::function<Expected<std::unique_ptr<MCStreamer>>(MCContext &)>;
434 llvm_unreachable("addAsmPrinter is not overridden");
435 }
436
437 /// Utilities for targets to add passes to the pass manager.
438 ///
439
440 /// createTargetRegisterAllocator - Create the register allocator pass for
441 /// this target at the current optimization level.
442 void addTargetRegisterAllocator(AddMachinePass &, bool Optimized) const;
443
444 /// addMachinePasses helper to create the target-selected or overriden
445 /// regalloc pass.
446 void addRegAllocPass(AddMachinePass &, bool Optimized) const;
447
448 /// Add core register alloator passes which do the actual register assignment
449 /// and rewriting. \returns true if any passes were added.
450 Error addRegAssignmentFast(AddMachinePass &) const;
451 Error addRegAssignmentOptimized(AddMachinePass &) const;
452
453private:
454 DerivedT &derived() { return static_cast<DerivedT &>(*this); }
455 const DerivedT &derived() const {
456 return static_cast<const DerivedT &>(*this);
457 }
458};
459
460template <typename Derived>
464 CodeGenFileType FileType) const {
465 AddIRPass addIRPass(MPM, Opt.DebugPM);
466 addISelPasses(addIRPass);
467
468 AddMachinePass addPass(MFPM);
469 if (auto Err = addCoreISelPasses(addPass))
470 return std::move(Err);
471
472 if (auto Err = derived().addMachinePasses(addPass))
473 return std::move(Err);
474
475 derived().addAsmPrinter(
476 addPass, [this, &Out, DwoOut, FileType](MCContext &Ctx) {
477 return this->TM.createMCStreamer(Out, DwoOut, FileType, Ctx);
478 });
479
480 addPass(FreeMachineFunctionPass());
481 return Error::success();
482}
483
485 AAManager AA;
486
487 // The order in which these are registered determines their priority when
488 // being queried.
489
490 // Basic AliasAnalysis support.
491 // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that
492 // BasicAliasAnalysis wins if they disagree. This is intended to help
493 // support "obvious" type-punning idioms.
497
498 return AA;
499}
500
501template <typename Derived>
503 ModuleAnalysisManager &MAM) const {
504#define MODULE_ANALYSIS(NAME, PASS_NAME, CONSTRUCTOR) \
505 MAM.registerPass([&] { return PASS_NAME CONSTRUCTOR; });
506#include "MachinePassRegistry.def"
507 derived().registerTargetAnalysis(MAM);
508}
509
510template <typename Derived>
513 FAM.registerPass([this] { return registerAAAnalyses(); });
514
515#define FUNCTION_ANALYSIS(NAME, PASS_NAME, CONSTRUCTOR) \
516 FAM.registerPass([&] { return PASS_NAME CONSTRUCTOR; });
517#include "MachinePassRegistry.def"
518 derived().registerTargetAnalysis(FAM);
519}
520
521template <typename Derived>
523 MachineFunctionAnalysisManager &MFAM) const {
524#define MACHINE_FUNCTION_ANALYSIS(NAME, PASS_NAME, CONSTRUCTOR) \
525 MFAM.registerPass([&] { return PASS_NAME CONSTRUCTOR; });
526#include "MachinePassRegistry.def"
527 derived().registerTargetAnalysis(MFAM);
528}
529
530// FIXME: For new PM, use pass name directly in commandline seems good.
531// Translate stringfied pass name to its old commandline name. Returns the
532// matching legacy name and a boolean value indicating if the pass is a machine
533// pass.
534template <typename Derived>
535std::pair<StringRef, bool>
537 std::pair<StringRef, bool> Ret;
538 if (Name.empty())
539 return Ret;
540
541#define FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
542 if (Name == NAME) \
543 Ret = {#PASS_NAME, false};
544#define DUMMY_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
545 if (Name == NAME) \
546 Ret = {#PASS_NAME, false};
547#define MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
548 if (Name == NAME) \
549 Ret = {#PASS_NAME, false};
550#define DUMMY_MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
551 if (Name == NAME) \
552 Ret = {#PASS_NAME, false};
553#define MACHINE_MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
554 if (Name == NAME) \
555 Ret = {#PASS_NAME, true};
556#define DUMMY_MACHINE_MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
557 if (Name == NAME) \
558 Ret = {#PASS_NAME, true};
559#define MACHINE_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
560 if (Name == NAME) \
561 Ret = {#PASS_NAME, true};
562#define DUMMY_MACHINE_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
563 if (Name == NAME) \
564 Ret = {#PASS_NAME, true};
565#include "llvm/CodeGen/MachinePassRegistry.def"
566
567 if (Ret.first.empty())
568 Ret = derived().getTargetPassNameFromLegacyName(Name);
569
570 if (Ret.first.empty())
572 Twine("\" pass could not be found."));
573
574 return Ret;
575}
576
577template <typename Derived>
579 if (TM.useEmulatedTLS())
580 addPass(LowerEmuTLSPass());
581
583
584 derived().addIRPasses(addPass);
585 derived().addCodeGenPrepare(addPass);
586 addPassesToHandleExceptions(addPass);
587 derived().addISelPrepare(addPass);
588}
589
590/// Add common target configurable passes that perform LLVM IR to IR transforms
591/// following machine independent optimization.
592template <typename Derived>
594 // Before running any passes, run the verifier to determine if the input
595 // coming from the front-end and/or optimizer is valid.
596 if (!Opt.DisableVerify)
597 addPass(VerifierPass());
598
599 // Run loop strength reduction before anything else.
600 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableLSR) {
602 LoopStrengthReducePass(), /*UseMemorySSA*/ true, Opt.DebugPM));
603 // FIXME: use -stop-after so we could remove PrintLSR
604 if (Opt.PrintLSR)
605 addPass(PrintFunctionPass(dbgs(), "\n\n*** Code after LSR ***\n"));
606 }
607
608 if (getOptLevel() != CodeGenOptLevel::None) {
609 // The MergeICmpsPass tries to create memcmp calls by grouping sequences of
610 // loads and compares. ExpandMemCmpPass then tries to expand those calls
611 // into optimally-sized loads and compares. The transforms are enabled by a
612 // target lowering hook.
613 if (!Opt.DisableMergeICmps)
614 addPass(MergeICmpsPass());
615 addPass(ExpandMemCmpPass());
616 }
617
618 // Run GC lowering passes for builtin collectors
619 // TODO: add a pass insertion point here
620 addPass(GCLoweringPass());
621 addPass(ShadowStackGCLoweringPass());
623
624 // Make sure that no unreachable blocks are instruction selected.
625 addPass(UnreachableBlockElimPass());
626
627 // Prepare expensive constants for SelectionDAG.
628 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableConstantHoisting)
629 addPass(ConstantHoistingPass());
630
631 // Replace calls to LLVM intrinsics (e.g., exp, log) operating on vector
632 // operands with calls to the corresponding functions in a vector library.
633 if (getOptLevel() != CodeGenOptLevel::None)
634 addPass(ReplaceWithVeclib());
635
636 if (getOptLevel() != CodeGenOptLevel::None &&
637 !Opt.DisablePartialLibcallInlining)
639
640 // Instrument function entry and exit, e.g. with calls to mcount().
641 addPass(EntryExitInstrumenterPass(/*PostInlining=*/true));
642
643 // Add scalarization of target's unsupported masked memory intrinsics pass.
644 // the unsupported intrinsic will be replaced with a chain of basic blocks,
645 // that stores/loads element one-by-one if the appropriate mask bit is set.
647
648 // Expand reduction intrinsics into shuffle sequences if the target wants to.
649 addPass(ExpandReductionsPass());
650
651 // Convert conditional moves to conditional jumps when profitable.
652 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableSelectOptimize)
653 addPass(SelectOptimizePass());
654}
655
656/// Turn exception handling constructs into something the code generators can
657/// handle.
658template <typename Derived>
660 AddIRPass &addPass) const {
661 const MCAsmInfo *MCAI = TM.getMCAsmInfo();
662 assert(MCAI && "No MCAsmInfo");
663 switch (MCAI->getExceptionHandlingType()) {
665 // SjLj piggy-backs on dwarf for this bit. The cleanups done apply to both
666 // Dwarf EH prepare needs to be run after SjLj prepare. Otherwise,
667 // catch info can get misplaced when a selector ends up more than one block
668 // removed from the parent invoke(s). This could happen when a landing
669 // pad is shared by multiple invokes and is also a target of a normal
670 // edge from elsewhere.
671 addPass(SjLjEHPreparePass());
672 [[fallthrough]];
676 addPass(DwarfEHPass(getOptLevel()));
677 break;
679 // We support using both GCC-style and MSVC-style exceptions on Windows, so
680 // add both preparation passes. Each pass will only actually run if it
681 // recognizes the personality function.
682 addPass(WinEHPass());
683 addPass(DwarfEHPass(getOptLevel()));
684 break;
686 // Wasm EH uses Windows EH instructions, but it does not need to demote PHIs
687 // on catchpads and cleanuppads because it does not outline them into
688 // funclets. Catchswitch blocks are not lowered in SelectionDAG, so we
689 // should remove PHIs there.
690 addPass(WinEHPass(/*DemoteCatchSwitchPHIOnly=*/false));
691 addPass(WasmEHPass());
692 break;
694 addPass(LowerInvokePass());
695
696 // The lower invoke pass may create unreachable code. Remove it.
697 addPass(UnreachableBlockElimPass());
698 break;
699 }
700}
701
702/// Add pass to prepare the LLVM IR for code generation. This should be done
703/// before exception handling preparation passes.
704template <typename Derived>
706 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableCGP)
707 addPass(CodeGenPreparePass());
708 // TODO: Default ctor'd RewriteSymbolPass is no-op.
709 // addPass(RewriteSymbolPass());
710}
711
712/// Add common passes that perform LLVM IR to IR transforms in preparation for
713/// instruction selection.
714template <typename Derived>
716 derived().addPreISel(addPass);
717
718 addPass(CallBrPrepare());
719 // Add both the safe stack and the stack protection passes: each of them will
720 // only protect functions that have corresponding attributes.
721 addPass(SafeStackPass());
722 addPass(StackProtectorPass());
723
724 if (Opt.PrintISelInput)
725 addPass(PrintFunctionPass(dbgs(),
726 "\n\n*** Final LLVM Code input to ISel ***\n"));
727
728 // All passes which modify the LLVM IR are now complete; run the verifier
729 // to ensure that the IR is valid.
730 if (!Opt.DisableVerify)
731 addPass(VerifierPass());
732}
733
734template <typename Derived>
736 AddMachinePass &addPass) const {
737 // Enable FastISel with -fast-isel, but allow that to be overridden.
738 TM.setO0WantsFastISel(Opt.EnableFastISelOption.value_or(true));
739
740 // Determine an instruction selector.
741 enum class SelectorType { SelectionDAG, FastISel, GlobalISel };
742 SelectorType Selector;
743
744 if (Opt.EnableFastISelOption && *Opt.EnableFastISelOption == true)
745 Selector = SelectorType::FastISel;
746 else if ((Opt.EnableGlobalISelOption &&
747 *Opt.EnableGlobalISelOption == true) ||
748 (TM.Options.EnableGlobalISel &&
749 (!Opt.EnableGlobalISelOption ||
750 *Opt.EnableGlobalISelOption == false)))
751 Selector = SelectorType::GlobalISel;
752 else if (TM.getOptLevel() == CodeGenOptLevel::None && TM.getO0WantsFastISel())
753 Selector = SelectorType::FastISel;
754 else
755 Selector = SelectorType::SelectionDAG;
756
757 // Set consistently TM.Options.EnableFastISel and EnableGlobalISel.
758 if (Selector == SelectorType::FastISel) {
759 TM.setFastISel(true);
760 TM.setGlobalISel(false);
761 } else if (Selector == SelectorType::GlobalISel) {
762 TM.setFastISel(false);
763 TM.setGlobalISel(true);
764 }
765
766 // Add instruction selector passes.
767 if (Selector == SelectorType::GlobalISel) {
768 if (auto Err = derived().addIRTranslator(addPass))
769 return std::move(Err);
770
771 derived().addPreLegalizeMachineIR(addPass);
772
773 if (auto Err = derived().addLegalizeMachineIR(addPass))
774 return std::move(Err);
775
776 // Before running the register bank selector, ask the target if it
777 // wants to run some passes.
778 derived().addPreRegBankSelect(addPass);
779
780 if (auto Err = derived().addRegBankSelect(addPass))
781 return std::move(Err);
782
783 derived().addPreGlobalInstructionSelect(addPass);
784
785 if (auto Err = derived().addGlobalInstructionSelect(addPass))
786 return std::move(Err);
787
788 // Pass to reset the MachineFunction if the ISel failed.
789 addPass(ResetMachineFunctionPass(reportDiagnosticWhenGlobalISelFallback(),
790 isGlobalISelAbortEnabled()));
791
792 // Provide a fallback path when we do not want to abort on
793 // not-yet-supported input.
794 if (!isGlobalISelAbortEnabled())
795 if (auto Err = derived().addInstSelector(addPass))
796 return std::move(Err);
797
798 } else if (auto Err = derived().addInstSelector(addPass))
799 return std::move(Err);
800
801 // Expand pseudo-instructions emitted by ISel. Don't run the verifier before
802 // FinalizeISel.
803 addPass(FinalizeISelPass());
804
805 // // Print the instruction selected machine code...
806 // printAndVerify("After Instruction Selection");
807
808 return Error::success();
809}
810
811/// Add the complete set of target-independent postISel code generator passes.
812///
813/// This can be read as the standard order of major LLVM CodeGen stages. Stages
814/// with nontrivial configuration or multiple passes are broken out below in
815/// add%Stage routines.
816///
817/// Any CodeGenPassBuilder<Derived>::addXX routine may be overriden by the
818/// Target. The addPre/Post methods with empty header implementations allow
819/// injecting target-specific fixups just before or after major stages.
820/// Additionally, targets have the flexibility to change pass order within a
821/// stage by overriding default implementation of add%Stage routines below. Each
822/// technique has maintainability tradeoffs because alternate pass orders are
823/// not well supported. addPre/Post works better if the target pass is easily
824/// tied to a common pass. But if it has subtle dependencies on multiple passes,
825/// the target should override the stage instead.
826template <typename Derived>
828 AddMachinePass &addPass) const {
829 // Add passes that optimize machine instructions in SSA form.
830 if (getOptLevel() != CodeGenOptLevel::None) {
831 derived().addMachineSSAOptimization(addPass);
832 } else {
833 // If the target requests it, assign local variables to stack slots relative
834 // to one another and simplify frame index references where possible.
835 addPass(LocalStackSlotPass());
836 }
837
838 if (TM.Options.EnableIPRA)
839 addPass(RegUsageInfoPropagationPass());
840
841 // Run pre-ra passes.
842 derived().addPreRegAlloc(addPass);
843
844 // Run register allocation and passes that are tightly coupled with it,
845 // including phi elimination and scheduling.
846 if (*Opt.OptimizeRegAlloc) {
847 derived().addOptimizedRegAlloc(addPass);
848 } else {
849 if (auto Err = derived().addFastRegAlloc(addPass))
850 return Err;
851 }
852
853 // Run post-ra passes.
854 derived().addPostRegAlloc(addPass);
855
856 addPass(RemoveRedundantDebugValuesPass());
857
858 // Insert prolog/epilog code. Eliminate abstract frame index references...
859 if (getOptLevel() != CodeGenOptLevel::None) {
860 addPass(PostRAMachineSinkingPass());
861 addPass(ShrinkWrapPass());
862 }
863
864 addPass(PrologEpilogInserterPass());
865
866 /// Add passes that optimize machine instructions after register allocation.
867 if (getOptLevel() != CodeGenOptLevel::None)
868 derived().addMachineLateOptimization(addPass);
869
870 // Expand pseudo instructions before second scheduling pass.
871 addPass(ExpandPostRAPseudosPass());
872
873 // Run pre-sched2 passes.
874 derived().addPreSched2(addPass);
875
876 if (Opt.EnableImplicitNullChecks)
877 addPass(ImplicitNullChecksPass());
878
879 // Second pass scheduler.
880 // Let Target optionally insert this pass by itself at some other
881 // point.
882 if (getOptLevel() != CodeGenOptLevel::None &&
883 !TM.targetSchedulesPostRAScheduling()) {
884 if (Opt.MISchedPostRA)
885 addPass(PostMachineSchedulerPass());
886 else
887 addPass(PostRASchedulerPass());
888 }
889
890 // GC
891 derived().addGCPasses(addPass);
892
893 // Basic block placement.
894 if (getOptLevel() != CodeGenOptLevel::None)
895 derived().addBlockPlacement(addPass);
896
897 // Insert before XRay Instrumentation.
898 addPass(FEntryInserterPass());
899
900 addPass(XRayInstrumentationPass());
901 addPass(PatchableFunctionPass());
902
903 derived().addPreEmitPass(addPass);
904
905 if (TM.Options.EnableIPRA)
906 // Collect register usage information and produce a register mask of
907 // clobbered registers, to be used to optimize call sites.
908 addPass(RegUsageInfoCollectorPass());
909
910 addPass(FuncletLayoutPass());
911
912 addPass(StackMapLivenessPass());
913 addPass(LiveDebugValuesPass());
914 addPass(MachineSanitizerBinaryMetadata());
915
916 if (TM.Options.EnableMachineOutliner &&
917 getOptLevel() != CodeGenOptLevel::None &&
918 Opt.EnableMachineOutliner != RunOutliner::NeverOutline) {
919 bool RunOnAllFunctions =
920 (Opt.EnableMachineOutliner == RunOutliner::AlwaysOutline);
921 bool AddOutliner = RunOnAllFunctions || TM.Options.SupportsDefaultOutlining;
922 if (AddOutliner)
923 addPass(MachineOutlinerPass(RunOnAllFunctions));
924 }
925
926 // Add passes that directly emit MI after all other MI passes.
927 derived().addPreEmitPass2(addPass);
928
929 return Error::success();
930}
931
932/// Add passes that optimize machine instructions in SSA form.
933template <typename Derived>
935 AddMachinePass &addPass) const {
936 // Pre-ra tail duplication.
937 addPass(EarlyTailDuplicatePass());
938
939 // Optimize PHIs before DCE: removing dead PHI cycles may make more
940 // instructions dead.
941 addPass(OptimizePHIsPass());
942
943 // This pass merges large allocas. StackSlotColoring is a different pass
944 // which merges spill slots.
945 addPass(StackColoringPass());
946
947 // If the target requests it, assign local variables to stack slots relative
948 // to one another and simplify frame index references where possible.
949 addPass(LocalStackSlotPass());
950
951 // With optimization, dead code should already be eliminated. However
952 // there is one known exception: lowered code for arguments that are only
953 // used by tail calls, where the tail calls reuse the incoming stack
954 // arguments directly (see t11 in test/CodeGen/X86/sibcall.ll).
955 addPass(DeadMachineInstructionElimPass());
956
957 // Allow targets to insert passes that improve instruction level parallelism,
958 // like if-conversion. Such passes will typically need dominator trees and
959 // loop info, just like LICM and CSE below.
960 derived().addILPOpts(addPass);
961
962 addPass(EarlyMachineLICMPass());
963 addPass(MachineCSEPass());
964
965 addPass(MachineSinkingPass());
966
967 addPass(PeepholeOptimizerPass());
968 // Clean-up the dead code that may have been generated by peephole
969 // rewriting.
970 addPass(DeadMachineInstructionElimPass());
971}
972
973//===---------------------------------------------------------------------===//
974/// Register Allocation Pass Configuration
975//===---------------------------------------------------------------------===//
976
977/// Instantiate the default register allocator pass for this target for either
978/// the optimized or unoptimized allocation path. This will be added to the pass
979/// manager by addFastRegAlloc in the unoptimized case or addOptimizedRegAlloc
980/// in the optimized case.
981///
982/// A target that uses the standard regalloc pass order for fast or optimized
983/// allocation may still override this for per-target regalloc
984/// selection. But -regalloc=... always takes precedence.
985template <typename Derived>
987 AddMachinePass &addPass, bool Optimized) const {
988 if (Optimized)
989 addPass(RAGreedyPass());
990 else
991 addPass(RAFastPass());
992}
993
994/// Find and instantiate the register allocation pass requested by this target
995/// at the current optimization level. Different register allocators are
996/// defined as separate passes because they may require different analysis.
997template <typename Derived>
999 bool Optimized) const {
1000 if (Opt.RegAlloc == RegAllocType::Default)
1001 // With no -regalloc= override, ask the target for a regalloc pass.
1002 derived().addTargetRegisterAllocator(addPass, Optimized);
1003 else if (Opt.RegAlloc == RegAllocType::Basic)
1004 addPass(RABasicPass());
1005 else if (Opt.RegAlloc == RegAllocType::Fast)
1006 addPass(RAFastPass());
1007 else if (Opt.RegAlloc == RegAllocType::Greedy)
1008 addPass(RAGreedyPass());
1009 else if (Opt.RegAlloc == RegAllocType::PBQP)
1010 addPass(RAPBQPPass());
1011 else
1012 llvm_unreachable("unknonwn register allocator type");
1013}
1014
1015template <typename Derived>
1017 AddMachinePass &addPass) const {
1018 if (Opt.RegAlloc != RegAllocType::Default &&
1019 Opt.RegAlloc != RegAllocType::Fast)
1020 return make_error<StringError>(
1021 "Must use fast (default) register allocator for unoptimized regalloc.",
1023
1024 addRegAllocPass(addPass, false);
1025 return Error::success();
1026}
1027
1028template <typename Derived>
1030 AddMachinePass &addPass) const {
1031 // Add the selected register allocation pass.
1032 addRegAllocPass(addPass, true);
1033
1034 // Allow targets to change the register assignments before rewriting.
1035 derived().addPreRewrite(addPass);
1036
1037 // Finally rewrite virtual registers.
1038 addPass(VirtRegRewriterPass());
1039 // Perform stack slot coloring and post-ra machine LICM.
1040 //
1041 // FIXME: Re-enable coloring with register when it's capable of adding
1042 // kill markers.
1043 addPass(StackSlotColoringPass());
1044
1045 return Error::success();
1046}
1047
1048/// Add the minimum set of target-independent passes that are required for
1049/// register allocation. No coalescing or scheduling.
1050template <typename Derived>
1052 AddMachinePass &addPass) const {
1053 addPass(PHIEliminationPass());
1054 addPass(TwoAddressInstructionPass());
1055 return derived().addRegAssignmentFast(addPass);
1056}
1057
1058/// Add standard target-independent passes that are tightly coupled with
1059/// optimized register allocation, including coalescing, machine instruction
1060/// scheduling, and register allocation itself.
1061template <typename Derived>
1063 AddMachinePass &addPass) const {
1064 addPass(DetectDeadLanesPass());
1065
1066 addPass(ProcessImplicitDefsPass());
1067
1068 // Edge splitting is smarter with machine loop info.
1069 addPass(PHIEliminationPass());
1070
1071 // Eventually, we want to run LiveIntervals before PHI elimination.
1072 if (Opt.EarlyLiveIntervals)
1073 addPass(LiveIntervalsPass());
1074
1075 addPass(TwoAddressInstructionPass());
1076 addPass(RegisterCoalescerPass());
1077
1078 // The machine scheduler may accidentally create disconnected components
1079 // when moving subregister definitions around, avoid this by splitting them to
1080 // separate vregs before. Splitting can also improve reg. allocation quality.
1081 addPass(RenameIndependentSubregsPass());
1082
1083 // PreRA instruction scheduling.
1084 addPass(MachineSchedulerPass());
1085
1086 if (derived().addRegAssignmentOptimized(addPass)) {
1087 // Allow targets to expand pseudo instructions depending on the choice of
1088 // registers before MachineCopyPropagation.
1089 derived().addPostRewrite(addPass);
1090
1091 // Copy propagate to forward register uses and try to eliminate COPYs that
1092 // were not coalesced.
1093 addPass(MachineCopyPropagationPass());
1094
1095 // Run post-ra machine LICM to hoist reloads / remats.
1096 //
1097 // FIXME: can this move into MachineLateOptimization?
1098 addPass(MachineLICMPass());
1099 }
1100}
1101
1102//===---------------------------------------------------------------------===//
1103/// Post RegAlloc Pass Configuration
1104//===---------------------------------------------------------------------===//
1105
1106/// Add passes that optimize machine instructions after register allocation.
1107template <typename Derived>
1109 AddMachinePass &addPass) const {
1110 // Branch folding must be run after regalloc and prolog/epilog insertion.
1111 addPass(BranchFolderPass());
1112
1113 // Tail duplication.
1114 // Note that duplicating tail just increases code size and degrades
1115 // performance for targets that require Structured Control Flow.
1116 // In addition it can also make CFG irreducible. Thus we disable it.
1117 if (!TM.requiresStructuredCFG())
1118 addPass(TailDuplicatePass());
1119
1120 // Cleanup of redundant (identical) address/immediate loads.
1121 addPass(MachineLateInstrsCleanupPass());
1122
1123 // Copy propagation.
1124 addPass(MachineCopyPropagationPass());
1125}
1126
1127/// Add standard basic block placement passes.
1128template <typename Derived>
1130 AddMachinePass &addPass) const {
1131 addPass(MachineBlockPlacementPass());
1132 // Run a separate pass to collect block placement statistics.
1133 if (Opt.EnableBlockPlacementStats)
1134 addPass(MachineBlockPlacementStatsPass());
1135}
1136
1137} // namespace llvm
1138
1139#endif // LLVM_CODEGEN_CODEGENPASSBUILDER_H
This is the interface for LLVM's primary stateless and local alias analysis.
std::string Name
#define Check(C,...)
This file defines passes to print out IR in various granularities.
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.
ModulePassManager MPM
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
const char LLVMTargetMachineRef TM
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 defines the SmallVector class.
This pass exposes codegen information to IR-level passes.
This is the interface for a metadata-based TBAA.
A manager for alias analyses.
void registerFunctionAnalysis()
Register a specific AA result.
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:620
bool registerPass(PassBuilderT &&PassBuilder)
Register an analysis pass with the manager.
Definition: PassManager.h:836
Analysis pass providing a never-invalidated alias analysis result.
std::enable_if_t< is_detected< is_module_pass_t, PassT >::value &&!is_detected< is_function_pass_t, PassT >::value > operator()(PassT &&Pass)
AddIRPass(ModulePassManager &MPM, bool DebugPM, bool Check=true)
std::enable_if_t< is_detected< is_function_pass_t, PassT >::value > operator()(PassT &&Pass)
AddMachinePass(MachineFunctionPassManager &PM)
void insertPass(AnalysisKey *ID, PassT Pass)
MachineFunctionPassManager releasePM()
This class provides access to building LLVM's passes.
Error addLegalizeMachineIR(AddMachinePass &) const
This method should install a legalize pass, which converts the instruction sequence into one that can...
void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const
void addISelPasses(AddIRPass &) const
High level function that adds all passes necessary to go from llvm IR representation to the MI repres...
Error addInstSelector(AddMachinePass &) const
addInstSelector - This method should install an instruction selector pass, which converts from LLVM c...
PassInstrumentationCallbacks * getPassInstrumentationCallbacks() const
Error buildPipeline(ModulePassManager &MPM, MachineFunctionPassManager &MFPM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType) const
void addPreEmitPass(AddMachinePass &) const
This pass may be implemented by targets that want to run passes immediately before machine code is em...
Error addIRTranslator(AddMachinePass &) const
This method should install an IR translator pass, which converts from LLVM code to machine instructio...
Error addGlobalInstructionSelect(AddMachinePass &) const
This method should install a (global) instruction selector pass, which converts possibly generic inst...
void addPostRewrite(AddMachinePass &) const
Add passes to be run immediately after virtual registers are rewritten to physical registers.
Error addRegBankSelect(AddMachinePass &) const
This method should install a register bank selector pass, which assigns register banks to virtual reg...
void registerTargetAnalysis(ModuleAnalysisManager &) const
Target override these hooks to parse target-specific analyses.
void registerAnalyses(MachineFunctionAnalysisManager &MFAM) const
void addPreSched2(AddMachinePass &) const
This method may be implemented by targets that want to run passes after prolog-epilog insertion and b...
void addPreLegalizeMachineIR(AddMachinePass &) const
This method may be implemented by targets that want to run passes immediately before legalization.
void addOptimizedRegAlloc(AddMachinePass &) const
addOptimizedRegAlloc - Add passes related to register allocation.
void registerMachineFunctionAnalyses(MachineFunctionAnalysisManager &) const
decltype(std::declval< PassT & >().run(std::declval< Function & >(), std::declval< FunctionAnalysisManager & >())) is_function_pass_t
void addGCPasses(AddMachinePass &) const
addGCPasses - Add late codegen passes that analyze code for garbage collection.
void addMachineSSAOptimization(AddMachinePass &) const
Methods with trivial inline returns are convenient points in the common codegen pass pipeline where t...
Error addRegAssignmentOptimized(AddMachinePass &) const
void registerModuleAnalyses(ModuleAnalysisManager &) const
Error addCoreISelPasses(AddMachinePass &) const
Add the actual instruction selection passes.
PassInstrumentationCallbacks * PIC
void addPassesToHandleExceptions(AddIRPass &) const
Add passes to lower exception handling for the code generator.
void addPreGlobalInstructionSelect(AddMachinePass &) const
This method may be implemented by targets that want to run passes immediately before the (global) ins...
void addMachineLateOptimization(AddMachinePass &) const
Add passes that optimize machine instructions after register allocation.
void addISelPrepare(AddIRPass &) const
Add common passes that perform LLVM IR to IR transforms in preparation for instruction selection.
void addPostRegAlloc(AddMachinePass &) const
This method may be implemented by targets that want to run passes after register allocation pass pipe...
std::pair< StringRef, bool > getPassNameFromLegacyName(StringRef) const
void addCodeGenPrepare(AddIRPass &) const
Add pass to prepare the LLVM IR for code generation.
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 addPreRegBankSelect(AddMachinePass &) const
This method may be implemented by targets that want to run passes immediately before the register ban...
decltype(std::declval< PassT & >().run(std::declval< Module & >(), std::declval< ModuleAnalysisManager & >())) is_module_pass_t
void addBlockPlacement(AddMachinePass &) const
Add standard basic block placement passes.
void registerTargetAnalysis(MachineFunctionAnalysisManager &) const
bool isGlobalISelAbortEnabled() const
Check whether or not GlobalISel should abort on error.
CodeGenOptLevel getOptLevel() const
void addPreEmitPass2(AddMachinePass &) const
Targets may add passes immediately before machine code is emitted in this callback.
std::function< Expected< std::unique_ptr< MCStreamer > >(MCContext &)> CreateMCStreamer
std::pair< StringRef, bool > getTargetPassNameFromLegacyName(StringRef) const
void addIRPasses(AddIRPass &) const
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
void addRegAllocPass(AddMachinePass &, bool Optimized) const
addMachinePasses helper to create the target-selected or overriden regalloc pass.
void registerTargetAnalysis(FunctionAnalysisManager &) const
void addILPOpts(AddMachinePass &) const
Add passes that optimize instruction level parallelism for out-of-order targets.
Error addRegAssignmentFast(AddMachinePass &) const
Add core register alloator passes which do the actual register assignment and rewriting.
void addPreRewrite(AddMachinePass &) const
addPreRewrite - Add passes to the optimized register allocation pipeline after register allocation is...
decltype(PassT::Key) has_key_t
Error addMachinePasses(AddMachinePass &) const
Add the complete, standard set of LLVM CodeGen passes.
CodeGenPassBuilder(LLVMTargetMachine &TM, CGPassBuilderOption Opts, PassInstrumentationCallbacks *PIC)
void addPreRegAlloc(AddMachinePass &) const
This method may be implemented by targets that want to run passes immediately before register allocat...
void registerFunctionAnalyses(FunctionAnalysisManager &) const
void addTargetRegisterAllocator(AddMachinePass &, bool Optimized) const
Utilities for targets to add passes to the pass manager.
Error addFastRegAlloc(AddMachinePass &) const
addFastRegAlloc - Add the minimum set of target-independent passes that are required for fast registe...
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
static ErrorSuccess success()
Create a success value.
Definition: Error.h:334
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
Definition: FastISel.h:66
This class describes a target machine that is implemented with the LLVM target-independent code gener...
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:781
Context object for machine code objects.
Definition: MCContext.h:76
An AnalysisManager<MachineFunction> that also exposes IR analysis results.
MachineFunctionPassManager adds/removes below features to/from the base PassManager template instanti...
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!std::is_same< PassT, PassManager >::value > addPass(PassT &&Pass)
Definition: PassManager.h:544
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.
Analysis pass providing a never-invalidated alias analysis result.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:225
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1200
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
TargetOptions Options
CodeGenOptLevel getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
GlobalISelAbortMode GlobalISelAbort
EnableGlobalISelAbort - Control abort behaviour when global instruction selection fails to lower/sele...
unsigned EnableIPRA
This flag enables InterProcedural Register Allocation (IPRA).
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
Analysis pass providing a never-invalidated alias analysis result.
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:428
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
@ 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
static AAManager registerAAAnalyses()
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:1218
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:90
@ SjLj
setjmp/longjmp based exceptions
@ None
No exception support.
@ AIX
AIX Exception Handling.
@ DwarfCFI
DWARF-like instruction based exceptions.
@ WinEH
Windows Exception Handling.
@ Wasm
WebAssembly Exception Handling.
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:80
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
Definition: CodeGen.h:83
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:156
CodeGenOptLevel
Code generation optimization level.
Definition: CodeGen.h:54
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.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:69
std::optional< bool > EnableIPRA
std::optional< bool > OptimizeRegAlloc
std::optional< GlobalISelAbortMode > EnableGlobalISelAbort