LLVM 22.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"
69#include "llvm/CodeGen/PEI.h"
106#include "llvm/IR/PassManager.h"
107#include "llvm/IR/Verifier.h"
109#include "llvm/MC/MCAsmInfo.h"
111#include "llvm/Support/CodeGen.h"
112#include "llvm/Support/Debug.h"
113#include "llvm/Support/Error.h"
130#include <cassert>
131#include <utility>
132
133namespace llvm {
134
135// FIXME: Dummy target independent passes definitions that have not yet been
136// ported to new pass manager. Once they do, remove these.
137#define DUMMY_FUNCTION_PASS(NAME, PASS_NAME) \
138 struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
139 template <typename... Ts> PASS_NAME(Ts &&...) {} \
140 PreservedAnalyses run(Function &, FunctionAnalysisManager &) { \
141 return PreservedAnalyses::all(); \
142 } \
143 };
144#define DUMMY_MACHINE_MODULE_PASS(NAME, PASS_NAME) \
145 struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
146 template <typename... Ts> PASS_NAME(Ts &&...) {} \
147 PreservedAnalyses run(Module &, ModuleAnalysisManager &) { \
148 return PreservedAnalyses::all(); \
149 } \
150 };
151#define DUMMY_MACHINE_FUNCTION_PASS(NAME, PASS_NAME) \
152 struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
153 template <typename... Ts> PASS_NAME(Ts &&...) {} \
154 PreservedAnalyses run(MachineFunction &, \
155 MachineFunctionAnalysisManager &) { \
156 return PreservedAnalyses::all(); \
157 } \
158 };
159#include "llvm/Passes/MachinePassRegistry.def"
160
161class PassManagerWrapper {
162private:
163 PassManagerWrapper(ModulePassManager &ModulePM) : MPM(ModulePM) {};
164
168
169 template <typename DerivedT, typename TargetMachineT>
170 friend class CodeGenPassBuilder;
171};
172
173/// This class provides access to building LLVM's passes.
174///
175/// Its members provide the baseline state available to passes during their
176/// construction. The \c MachinePassRegistry.def file specifies how to construct
177/// all of the built-in passes, and those may reference these members during
178/// construction.
179template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
180public:
181 explicit CodeGenPassBuilder(TargetMachineT &TM,
182 const CGPassBuilderOption &Opts,
184 : TM(TM), Opt(Opts), PIC(PIC) {
185 // Target could set CGPassBuilderOption::MISchedPostRA to true to achieve
186 // substitutePass(&PostRASchedulerID, &PostMachineSchedulerID)
187
188 // Target should override TM.Options.EnableIPRA in their target-specific
189 // LLVMTM ctor. See TargetMachine::setGlobalISel for example.
190 if (Opt.EnableIPRA) {
191 TM.Options.EnableIPRA = *Opt.EnableIPRA;
192 } else {
193 // If not explicitly specified, use target default.
194 TM.Options.EnableIPRA |= TM.useIPRA();
195 }
196
197 if (Opt.EnableGlobalISelAbort)
198 TM.Options.GlobalISelAbort = *Opt.EnableGlobalISelAbort;
199
200 if (!Opt.OptimizeRegAlloc)
201 Opt.OptimizeRegAlloc = getOptLevel() != CodeGenOptLevel::None;
202 }
203
205 raw_pwrite_stream *DwoOut,
206 CodeGenFileType FileType) const;
207
211
212protected:
213 template <typename PassT>
214 using is_module_pass_t = decltype(std::declval<PassT &>().run(
215 std::declval<Module &>(), std::declval<ModuleAnalysisManager &>()));
216
217 template <typename PassT>
218 using is_function_pass_t = decltype(std::declval<PassT &>().run(
219 std::declval<Function &>(), std::declval<FunctionAnalysisManager &>()));
220
221 template <typename PassT>
222 using is_machine_function_pass_t = decltype(std::declval<PassT &>().run(
223 std::declval<MachineFunction &>(),
224 std::declval<MachineFunctionAnalysisManager &>()));
225
226 template <typename PassT>
228 bool Force = false,
229 StringRef Name = PassT::name()) const {
231 "Only function passes are supported.");
232 if (!Force && !runBeforeAdding(Name))
233 return;
234 PMW.FPM.addPass(std::forward<PassT>(Pass));
235 }
236
237 template <typename PassT>
238 void addModulePass(PassT &&Pass, PassManagerWrapper &PMW, bool Force = false,
239 StringRef Name = PassT::name()) const {
241 "Only module passes are suported.");
242 assert(PMW.FPM.isEmpty() && PMW.MFPM.isEmpty() &&
243 "You cannot insert a module pass without first flushing the current "
244 "function pipelines to the module pipeline.");
245 if (!Force && !runBeforeAdding(Name))
246 return;
247 PMW.MPM.addPass(std::forward<PassT>(Pass));
248 }
249
250 template <typename PassT>
252 bool Force = false,
253 StringRef Name = PassT::name()) const {
255 "Only machine function passes are supported.");
256
257 if (!Force && !runBeforeAdding(Name))
258 return;
259 PMW.MFPM.addPass(std::forward<PassT>(Pass));
260 for (auto &C : AfterCallbacks)
261 C(Name, PMW.MFPM);
262 }
263
265 bool FreeMachineFunctions = false) const {
266 if (PMW.FPM.isEmpty() && PMW.MFPM.isEmpty())
267 return;
268 if (!PMW.MFPM.isEmpty()) {
269 PMW.FPM.addPass(
270 createFunctionToMachineFunctionPassAdaptor(std::move(PMW.MFPM)));
271 PMW.MFPM = MachineFunctionPassManager();
272 }
273 if (FreeMachineFunctions)
275 if (AddInCGSCCOrder) {
277 createCGSCCToFunctionPassAdaptor(std::move(PMW.FPM))));
278 } else {
279 PMW.MPM.addPass(createModuleToFunctionPassAdaptor(std::move(PMW.FPM)));
280 }
281 PMW.FPM = FunctionPassManager();
282 }
283
285 assert(!AddInCGSCCOrder);
286 flushFPMsToMPM(PMW);
287 AddInCGSCCOrder = true;
288 }
290 assert(AddInCGSCCOrder);
291 flushFPMsToMPM(PMW);
292 AddInCGSCCOrder = false;
293 }
294
295 TargetMachineT &TM;
298
299 template <typename TMC> TMC &getTM() const { return static_cast<TMC &>(TM); }
300 CodeGenOptLevel getOptLevel() const { return TM.getOptLevel(); }
301
302 /// Check whether or not GlobalISel should abort on error.
303 /// When this is disabled, GlobalISel will fall back on SDISel instead of
304 /// erroring out.
306 return TM.Options.GlobalISelAbort == GlobalISelAbortMode::Enable;
307 }
308
309 /// Check whether or not a diagnostic should be emitted when GlobalISel
310 /// uses the fallback path. In other words, it will emit a diagnostic
311 /// when GlobalISel failed and isGlobalISelAbortEnabled is false.
313 return TM.Options.GlobalISelAbort == GlobalISelAbortMode::DisableWithDiag;
314 }
315
316 /// addInstSelector - This method should install an instruction selector pass,
317 /// which converts from LLVM code to machine instructions.
319 return make_error<StringError>("addInstSelector is not overridden",
321 }
322
323 /// Target can override this to add GlobalMergePass before all IR passes.
325
326 /// Add passes that optimize instruction level parallelism for out-of-order
327 /// targets. These passes are run while the machine code is still in SSA
328 /// form, so they can use MachineTraceMetrics to control their heuristics.
329 ///
330 /// All passes added here should preserve the MachineDominatorTree,
331 /// MachineLoopInfo, and MachineTraceMetrics analyses.
332 void addILPOpts(PassManagerWrapper &PMW) const {}
333
334 /// This method may be implemented by targets that want to run passes
335 /// immediately before register allocation.
337
338 /// addPreRewrite - Add passes to the optimized register allocation pipeline
339 /// after register allocation is complete, but before virtual registers are
340 /// rewritten to physical registers.
341 ///
342 /// These passes must preserve VirtRegMap and LiveIntervals, and when running
343 /// after RABasic or RAGreedy, they should take advantage of LiveRegMatrix.
344 /// When these passes run, VirtRegMap contains legal physreg assignments for
345 /// all virtual registers.
346 ///
347 /// Note if the target overloads addRegAssignAndRewriteOptimized, this may not
348 /// be honored. This is also not generally used for the fast variant,
349 /// where the allocation and rewriting are done in one pass.
351
352 /// Add passes to be run immediately after virtual registers are rewritten
353 /// to physical registers.
355
356 /// This method may be implemented by targets that want to run passes after
357 /// register allocation pass pipeline but before prolog-epilog insertion.
359
360 /// This method may be implemented by targets that want to run passes after
361 /// prolog-epilog insertion and before the second instruction scheduling pass.
363
364 /// This pass may be implemented by targets that want to run passes
365 /// immediately before machine code is emitted.
367
368 /// Targets may add passes immediately before machine code is emitted in this
369 /// callback. This is called even later than `addPreEmitPass`.
370 // FIXME: Rename `addPreEmitPass` to something more sensible given its actual
371 // position and remove the `2` suffix here as this callback is what
372 // `addPreEmitPass` *should* be but in reality isn't.
374
375 /// {{@ For GlobalISel
376 ///
377
378 /// addPreISel - This method should add any "last minute" LLVM->LLVM
379 /// passes (which are run just before instruction selector).
381 llvm_unreachable("addPreISel is not overridden");
382 }
383
384 /// This method should install an IR translator pass, which converts from
385 /// LLVM code to machine instructions with possibly generic opcodes.
387 return make_error<StringError>("addIRTranslator is not overridden",
389 }
390
391 /// This method may be implemented by targets that want to run passes
392 /// immediately before legalization.
394
395 /// This method should install a legalize pass, which converts the instruction
396 /// sequence into one that can be selected by the target.
398 return make_error<StringError>("addLegalizeMachineIR is not overridden",
400 }
401
402 /// This method may be implemented by targets that want to run passes
403 /// immediately before the register bank selection.
405
406 /// This method should install a register bank selector pass, which
407 /// assigns register banks to virtual registers without a register
408 /// class or register banks.
410 return make_error<StringError>("addRegBankSelect is not overridden",
412 }
413
414 /// This method may be implemented by targets that want to run passes
415 /// immediately before the (global) instruction selection.
417
418 /// This method should install a (global) instruction selector pass, which
419 /// converts possibly generic instructions to fully target-specific
420 /// instructions, thereby constraining all generic virtual registers to
421 /// register classes.
424 "addGlobalInstructionSelect is not overridden",
426 }
427 /// @}}
428
429 /// High level function that adds all passes necessary to go from llvm IR
430 /// representation to the MI representation.
431 /// Adds IR based lowering and target specific optimization passes and finally
432 /// the core instruction selection passes.
434
435 /// Add the actual instruction selection passes. This does not include
436 /// preparation passes on IR.
438
439 /// Add the complete, standard set of LLVM CodeGen passes.
440 /// Fully developed targets will not generally override this.
442
443 /// Add passes to lower exception handling for the code generator.
445
446 /// Add common target configurable passes that perform LLVM IR to IR
447 /// transforms following machine independent optimization.
449
450 /// Add pass to prepare the LLVM IR for code generation. This should be done
451 /// before exception handling preparation passes.
453
454 /// Add common passes that perform LLVM IR to IR transforms in preparation for
455 /// instruction selection.
457
458 /// Methods with trivial inline returns are convenient points in the common
459 /// codegen pass pipeline where targets may insert passes. Methods with
460 /// out-of-line standard implementations are major CodeGen stages called by
461 /// addMachinePasses. Some targets may override major stages when inserting
462 /// passes is insufficient, but maintaining overriden stages is more work.
463 ///
464
465 /// addMachineSSAOptimization - Add standard passes that optimize machine
466 /// instructions in SSA form.
468
469 /// addFastRegAlloc - Add the minimum set of target-independent passes that
470 /// are required for fast register allocation.
472
473 /// addOptimizedRegAlloc - Add passes related to register allocation.
474 /// CodeGenTargetMachineImpl provides standard regalloc passes for most
475 /// targets.
477
478 /// Add passes that optimize machine instructions after register allocation.
480
481 /// addGCPasses - Add late codegen passes that analyze code for garbage
482 /// collection. This should return true if GC info should be printed after
483 /// these passes.
484 void addGCPasses(PassManagerWrapper &PMW) const {}
485
486 /// Add standard basic block placement passes.
488
490 std::function<Expected<std::unique_ptr<MCStreamer>>(MCContext &)>;
492 llvm_unreachable("addAsmPrinter is not overridden");
493 }
494
495 /// Utilities for targets to add passes to the pass manager.
496 ///
497
498 /// createTargetRegisterAllocator - Create the register allocator pass for
499 /// this target at the current optimization level.
501 bool Optimized) const;
502
503 /// addMachinePasses helper to create the target-selected or overriden
504 /// regalloc pass.
505 void addRegAllocPass(PassManagerWrapper &PMW, bool Optimized) const;
506
507 /// Add core register alloator passes which do the actual register assignment
508 /// and rewriting. \returns true if any passes were added.
511
512 /// Allow the target to disable a specific pass by default.
513 /// Backend can declare unwanted passes in constructor.
514 template <typename... PassTs> void disablePass() {
515 BeforeCallbacks.emplace_back(
516 [](StringRef Name) { return ((Name != PassTs::name()) && ...); });
517 }
518
519 /// Insert InsertedPass pass after TargetPass pass.
520 /// Only machine function passes are supported.
521 template <typename TargetPassT, typename InsertedPassT>
522 void insertPass(InsertedPassT &&Pass) const {
523 AfterCallbacks.emplace_back(
524 [&](StringRef Name, MachineFunctionPassManager &MFPM) mutable {
525 if (Name == TargetPassT::name() &&
526 runBeforeAdding(InsertedPassT::name())) {
527 MFPM.addPass(std::forward<InsertedPassT>(Pass));
528 }
529 });
530 }
531
532private:
533 DerivedT &derived() { return static_cast<DerivedT &>(*this); }
534 const DerivedT &derived() const {
535 return static_cast<const DerivedT &>(*this);
536 }
537
538 bool runBeforeAdding(StringRef Name) const {
539 bool ShouldAdd = true;
540 for (auto &C : BeforeCallbacks)
541 ShouldAdd &= C(Name);
542 return ShouldAdd;
543 }
544
545 void setStartStopPasses(const TargetPassConfig::StartStopInfo &Info) const;
546
547 Error verifyStartStop(const TargetPassConfig::StartStopInfo &Info) const;
548
549 mutable SmallVector<llvm::unique_function<bool(StringRef)>, 4>
550 BeforeCallbacks;
551 mutable SmallVector<
552 llvm::unique_function<void(StringRef, MachineFunctionPassManager &)>, 4>
553 AfterCallbacks;
554
555 /// Helper variable for `-start-before/-start-after/-stop-before/-stop-after`
556 mutable bool Started = true;
557 mutable bool Stopped = true;
558 mutable bool AddInCGSCCOrder = false;
559};
560
561template <typename Derived, typename TargetMachineT>
564 CodeGenFileType FileType) const {
565 auto StartStopInfo = TargetPassConfig::getStartStopInfo(*PIC);
566 if (!StartStopInfo)
567 return StartStopInfo.takeError();
568 setStartStopPasses(*StartStopInfo);
569
571 bool PrintMIR = !PrintAsm && FileType != CodeGenFileType::Null;
572
573 PassManagerWrapper PMW(MPM);
574
576 /*Force=*/true);
578 /*Force=*/true);
580 /*Force=*/true);
582 /*Force=*/true);
583 addISelPasses(PMW);
584 flushFPMsToMPM(PMW);
585
586 if (PrintMIR)
587 addModulePass(PrintMIRPreparePass(Out), PMW, /*Force=*/true);
588
589 if (auto Err = addCoreISelPasses(PMW))
590 return std::move(Err);
591
592 if (auto Err = derived().addMachinePasses(PMW))
593 return std::move(Err);
594
595 if (!Opt.DisableVerify)
597
598 if (PrintAsm) {
599 derived().addAsmPrinter(
600 PMW, [this, &Out, DwoOut, FileType](MCContext &Ctx) {
601 return this->TM.createMCStreamer(Out, DwoOut, FileType, Ctx);
602 });
603 }
604
605 if (PrintMIR)
606 addMachineFunctionPass(PrintMIRPass(Out), PMW, /*Force=*/true);
607
608 flushFPMsToMPM(PMW, /*FreeMachineFunctions=*/true);
609
610 return verifyStartStop(*StartStopInfo);
611}
612
613template <typename Derived, typename TargetMachineT>
614void CodeGenPassBuilder<Derived, TargetMachineT>::setStartStopPasses(
615 const TargetPassConfig::StartStopInfo &Info) const {
616 if (!Info.StartPass.empty()) {
617 Started = false;
618 BeforeCallbacks.emplace_back([this, &Info, AfterFlag = Info.StartAfter,
619 Count = 0u](StringRef ClassName) mutable {
620 if (Count == Info.StartInstanceNum) {
621 if (AfterFlag) {
622 AfterFlag = false;
623 Started = true;
624 }
625 return Started;
626 }
627
628 auto PassName = PIC->getPassNameForClassName(ClassName);
629 if (Info.StartPass == PassName && ++Count == Info.StartInstanceNum)
630 Started = !Info.StartAfter;
631
632 return Started;
633 });
634 }
635
636 if (!Info.StopPass.empty()) {
637 Stopped = false;
638 BeforeCallbacks.emplace_back([this, &Info, AfterFlag = Info.StopAfter,
639 Count = 0u](StringRef ClassName) mutable {
640 if (Count == Info.StopInstanceNum) {
641 if (AfterFlag) {
642 AfterFlag = false;
643 Stopped = true;
644 }
645 return !Stopped;
646 }
647
648 auto PassName = PIC->getPassNameForClassName(ClassName);
649 if (Info.StopPass == PassName && ++Count == Info.StopInstanceNum)
650 Stopped = !Info.StopAfter;
651 return !Stopped;
652 });
653 }
654}
655
656template <typename Derived, typename TargetMachineT>
657Error CodeGenPassBuilder<Derived, TargetMachineT>::verifyStartStop(
659 if (Started && Stopped)
660 return Error::success();
661
662 if (!Started)
664 "Can't find start pass \"" + Info.StartPass + "\".",
665 std::make_error_code(std::errc::invalid_argument));
666 if (!Stopped)
668 "Can't find stop pass \"" + Info.StopPass + "\".",
669 std::make_error_code(std::errc::invalid_argument));
670 return Error::success();
671}
672
673template <typename Derived, typename TargetMachineT>
675 PassManagerWrapper &PMW) const {
676 derived().addGlobalMergePass(PMW);
677 if (TM.useEmulatedTLS())
679
683
684 derived().addIRPasses(PMW);
685 derived().addCodeGenPrepare(PMW);
687 derived().addISelPrepare(PMW);
688}
689
690/// Add common target configurable passes that perform LLVM IR to IR transforms
691/// following machine independent optimization.
692template <typename Derived, typename TargetMachineT>
694 PassManagerWrapper &PMW) const {
695 // Before running any passes, run the verifier to determine if the input
696 // coming from the front-end and/or optimizer is valid.
697 if (!Opt.DisableVerify)
698 addFunctionPass(VerifierPass(), PMW, /*Force=*/true);
699
700 // Run loop strength reduction before anything else.
701 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableLSR) {
702 LoopPassManager LPM;
703 LPM.addPass(CanonicalizeFreezeInLoopsPass());
704 LPM.addPass(LoopStrengthReducePass());
705 if (Opt.EnableLoopTermFold)
706 LPM.addPass(LoopTermFoldPass());
708 /*UseMemorySSA=*/true),
709 PMW);
710 }
711
713 // The MergeICmpsPass tries to create memcmp calls by grouping sequences of
714 // loads and compares. ExpandMemCmpPass then tries to expand those calls
715 // into optimally-sized loads and compares. The transforms are enabled by a
716 // target lowering hook.
717 if (!Opt.DisableMergeICmps)
720 }
721
722 // Run GC lowering passes for builtin collectors
723 // TODO: add a pass insertion point here
725 // Explicitly check to see if we should add ShadowStackGCLowering to avoid
726 // splitting the function pipeline if we do not have to.
727 if (runBeforeAdding(ShadowStackGCLoweringPass::name())) {
728 flushFPMsToMPM(PMW);
730 }
732
733 // Make sure that no unreachable blocks are instruction selected.
735
736 // Prepare expensive constants for SelectionDAG.
737 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableConstantHoisting)
739
740 // Replace calls to LLVM intrinsics (e.g., exp, log) operating on vector
741 // operands with calls to the corresponding functions in a vector library.
744
746 !Opt.DisablePartialLibcallInlining)
748
749 // Instrument function entry and exit, e.g. with calls to mcount().
750 addFunctionPass(EntryExitInstrumenterPass(/*PostInlining=*/true), PMW);
751
752 // Add scalarization of target's unsupported masked memory intrinsics pass.
753 // the unsupported intrinsic will be replaced with a chain of basic blocks,
754 // that stores/loads element one-by-one if the appropriate mask bit is set.
756
757 // Expand reduction intrinsics into shuffle sequences if the target wants to.
758 if (!Opt.DisableExpandReductions)
760
761 // Convert conditional moves to conditional jumps when profitable.
762 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableSelectOptimize)
764
765 if (Opt.EnableGlobalMergeFunc) {
766 flushFPMsToMPM(PMW);
768 }
769}
770
771/// Turn exception handling constructs into something the code generators can
772/// handle.
773template <typename Derived, typename TargetMachineT>
775 PassManagerWrapper &PMW) const {
776 const MCAsmInfo *MCAI = TM.getMCAsmInfo();
777 assert(MCAI && "No MCAsmInfo");
778 switch (MCAI->getExceptionHandlingType()) {
780 // SjLj piggy-backs on dwarf for this bit. The cleanups done apply to both
781 // Dwarf EH prepare needs to be run after SjLj prepare. Otherwise,
782 // catch info can get misplaced when a selector ends up more than one block
783 // removed from the parent invoke(s). This could happen when a landing
784 // pad is shared by multiple invokes and is also a target of a normal
785 // edge from elsewhere.
787 [[fallthrough]];
793 break;
795 // We support using both GCC-style and MSVC-style exceptions on Windows, so
796 // add both preparation passes. Each pass will only actually run if it
797 // recognizes the personality function.
800 break;
802 // Wasm EH uses Windows EH instructions, but it does not need to demote PHIs
803 // on catchpads and cleanuppads because it does not outline them into
804 // funclets. Catchswitch blocks are not lowered in SelectionDAG, so we
805 // should remove PHIs there.
806 addFunctionPass(WinEHPreparePass(/*DemoteCatchSwitchPHIOnly=*/false), PMW);
808 break;
811
812 // The lower invoke pass may create unreachable code. Remove it.
814 break;
815 }
816}
817
818/// Add pass to prepare the LLVM IR for code generation. This should be done
819/// before exception handling preparation passes.
820template <typename Derived, typename TargetMachineT>
822 PassManagerWrapper &PMW) const {
823 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableCGP)
825 // TODO: Default ctor'd RewriteSymbolPass is no-op.
826 // addPass(RewriteSymbolPass());
827}
828
829/// Add common passes that perform LLVM IR to IR transforms in preparation for
830/// instruction selection.
831template <typename Derived, typename TargetMachineT>
833 PassManagerWrapper &PMW) const {
834 derived().addPreISel(PMW);
835
836 if (Opt.RequiresCodeGenSCCOrder && !AddInCGSCCOrder)
838
841
843 // Add both the safe stack and the stack protection passes: each of them will
844 // only protect functions that have corresponding attributes.
847
848 if (Opt.PrintISelInput)
850 dbgs(), "\n\n*** Final LLVM Code input to ISel ***\n"),
851 PMW);
852
853 // All passes which modify the LLVM IR are now complete; run the verifier
854 // to ensure that the IR is valid.
855 if (!Opt.DisableVerify)
856 addFunctionPass(VerifierPass(), PMW, /*Force=*/true);
857}
858
859template <typename Derived, typename TargetMachineT>
861 PassManagerWrapper &PMW) const {
862 // Enable FastISel with -fast-isel, but allow that to be overridden.
863 TM.setO0WantsFastISel(Opt.EnableFastISelOption.value_or(true));
864
865 // Determine an instruction selector.
866 enum class SelectorType { SelectionDAG, FastISel, GlobalISel };
867 SelectorType Selector;
868
869 if (Opt.EnableFastISelOption && *Opt.EnableFastISelOption == true)
870 Selector = SelectorType::FastISel;
871 else if ((Opt.EnableGlobalISelOption &&
872 *Opt.EnableGlobalISelOption == true) ||
873 (TM.Options.EnableGlobalISel &&
874 (!Opt.EnableGlobalISelOption ||
875 *Opt.EnableGlobalISelOption == false)))
876 Selector = SelectorType::GlobalISel;
877 else if (TM.getOptLevel() == CodeGenOptLevel::None && TM.getO0WantsFastISel())
878 Selector = SelectorType::FastISel;
879 else
880 Selector = SelectorType::SelectionDAG;
881
882 // Set consistently TM.Options.EnableFastISel and EnableGlobalISel.
883 if (Selector == SelectorType::FastISel) {
884 TM.setFastISel(true);
885 TM.setGlobalISel(false);
886 } else if (Selector == SelectorType::GlobalISel) {
887 TM.setFastISel(false);
888 TM.setGlobalISel(true);
889 }
890
891 // Add instruction selector passes.
892 if (Selector == SelectorType::GlobalISel) {
893 if (auto Err = derived().addIRTranslator(PMW))
894 return std::move(Err);
895
896 derived().addPreLegalizeMachineIR(PMW);
897
898 if (auto Err = derived().addLegalizeMachineIR(PMW))
899 return std::move(Err);
900
901 // Before running the register bank selector, ask the target if it
902 // wants to run some passes.
903 derived().addPreRegBankSelect(PMW);
904
905 if (auto Err = derived().addRegBankSelect(PMW))
906 return std::move(Err);
907
908 derived().addPreGlobalInstructionSelect(PMW);
909
910 if (auto Err = derived().addGlobalInstructionSelect(PMW))
911 return std::move(Err);
912
913 // Pass to reset the MachineFunction if the ISel failed.
915 ResetMachineFunctionPass(reportDiagnosticWhenGlobalISelFallback(),
917 PMW);
918
919 // Provide a fallback path when we do not want to abort on
920 // not-yet-supported input.
922 if (auto Err = derived().addInstSelector(PMW))
923 return std::move(Err);
924
925 } else if (auto Err = derived().addInstSelector(PMW))
926 return std::move(Err);
927
928 // Expand pseudo-instructions emitted by ISel. Don't run the verifier before
929 // FinalizeISel.
931
932 // // Print the instruction selected machine code...
933 // printAndVerify("After Instruction Selection");
934
935 return Error::success();
936}
937
938/// Add the complete set of target-independent postISel code generator passes.
939///
940/// This can be read as the standard order of major LLVM CodeGen stages. Stages
941/// with nontrivial configuration or multiple passes are broken out below in
942/// add%Stage routines.
943///
944/// Any CodeGenPassBuilder<Derived, TargetMachine>::addXX routine may be
945/// overriden by the Target. The addPre/Post methods with empty header
946/// implementations allow injecting target-specific fixups just before or after
947/// major stages. Additionally, targets have the flexibility to change pass
948/// order within a stage by overriding default implementation of add%Stage
949/// routines below. Each technique has maintainability tradeoffs because
950/// alternate pass orders are not well supported. addPre/Post works better if
951/// the target pass is easily tied to a common pass. But if it has subtle
952/// dependencies on multiple passes, the target should override the stage
953/// instead.
954template <typename Derived, typename TargetMachineT>
956 PassManagerWrapper &PMW) const {
957 // Add passes that optimize machine instructions in SSA form.
959 derived().addMachineSSAOptimization(PMW);
960 } else {
961 // If the target requests it, assign local variables to stack slots relative
962 // to one another and simplify frame index references where possible.
964 }
965
966 if (TM.Options.EnableIPRA) {
967 flushFPMsToMPM(PMW);
969 PMW);
971 }
972 // Run pre-ra passes.
973 derived().addPreRegAlloc(PMW);
974
975 // Run register allocation and passes that are tightly coupled with it,
976 // including phi elimination and scheduling.
977 if (*Opt.OptimizeRegAlloc) {
978 derived().addOptimizedRegAlloc(PMW);
979 } else {
980 if (auto Err = derived().addFastRegAlloc(PMW))
981 return Err;
982 }
983
984 // Run post-ra passes.
985 derived().addPostRegAlloc(PMW);
986
989
990 // Insert prolog/epilog code. Eliminate abstract frame index references...
994 }
995
997
998 /// Add passes that optimize machine instructions after register allocation.
1000 derived().addMachineLateOptimization(PMW);
1001
1002 // Expand pseudo instructions before second scheduling pass.
1004
1005 // Run pre-sched2 passes.
1006 derived().addPreSched2(PMW);
1007
1008 if (Opt.EnableImplicitNullChecks)
1009 addMachineFunctionPass(ImplicitNullChecksPass(), PMW);
1010
1011 // Second pass scheduler.
1012 // Let Target optionally insert this pass by itself at some other
1013 // point.
1015 !TM.targetSchedulesPostRAScheduling()) {
1016 if (Opt.MISchedPostRA)
1018 else
1020 }
1021
1022 // GC
1023 derived().addGCPasses(PMW);
1024
1025 // Basic block placement.
1027 derived().addBlockPlacement(PMW);
1028
1029 // Insert before XRay Instrumentation.
1031
1034
1035 derived().addPreEmitPass(PMW);
1036
1037 if (TM.Options.EnableIPRA) {
1038 // Collect register usage information and produce a register mask of
1039 // clobbered registers, to be used to optimize call sites.
1040 flushFPMsToMPM(PMW);
1042 PMW);
1044 }
1045
1046 addMachineFunctionPass(FuncletLayoutPass(), PMW);
1047
1049 addMachineFunctionPass(StackMapLivenessPass(), PMW);
1052 getTM<TargetMachine>().Options.ShouldEmitDebugEntryValues()),
1053 PMW);
1055
1056 if (TM.Options.EnableMachineOutliner &&
1058 Opt.EnableMachineOutliner != RunOutliner::NeverOutline) {
1059 if (Opt.EnableMachineOutliner != RunOutliner::TargetDefault ||
1060 TM.Options.SupportsDefaultOutlining) {
1061 flushFPMsToMPM(PMW);
1062 addModulePass(MachineOutlinerPass(Opt.EnableMachineOutliner), PMW);
1063 }
1064 }
1065
1067
1068 // Add passes that directly emit MI after all other MI passes.
1069 derived().addPreEmitPass2(PMW);
1070
1071 return Error::success();
1072}
1073
1074/// Add passes that optimize machine instructions in SSA form.
1075template <typename Derived, typename TargetMachineT>
1077 PassManagerWrapper &PMW) const {
1078 // Pre-ra tail duplication.
1080
1081 // Optimize PHIs before DCE: removing dead PHI cycles may make more
1082 // instructions dead.
1084
1085 // This pass merges large allocas. StackSlotColoring is a different pass
1086 // which merges spill slots.
1088
1089 // If the target requests it, assign local variables to stack slots relative
1090 // to one another and simplify frame index references where possible.
1092
1093 // With optimization, dead code should already be eliminated. However
1094 // there is one known exception: lowered code for arguments that are only
1095 // used by tail calls, where the tail calls reuse the incoming stack
1096 // arguments directly (see t11 in test/CodeGen/X86/sibcall.ll).
1098
1099 // Allow targets to insert passes that improve instruction level parallelism,
1100 // like if-conversion. Such passes will typically need dominator trees and
1101 // loop info, just like LICM and CSE below.
1102 derived().addILPOpts(PMW);
1103
1106
1107 addMachineFunctionPass(MachineSinkingPass(Opt.EnableSinkAndFold), PMW);
1108
1110 // Clean-up the dead code that may have been generated by peephole
1111 // rewriting.
1113}
1114
1115//===---------------------------------------------------------------------===//
1116/// Register Allocation Pass Configuration
1117//===---------------------------------------------------------------------===//
1118
1119/// Instantiate the default register allocator pass for this target for either
1120/// the optimized or unoptimized allocation path. This will be added to the pass
1121/// manager by addFastRegAlloc in the unoptimized case or addOptimizedRegAlloc
1122/// in the optimized case.
1123///
1124/// A target that uses the standard regalloc pass order for fast or optimized
1125/// allocation may still override this for per-target regalloc
1126/// selection. But -regalloc-npm=... always takes precedence.
1127/// If a target does not want to allow users to set -regalloc-npm=... at all,
1128/// check if Opt.RegAlloc == RegAllocType::Unset.
1129template <typename Derived, typename TargetMachineT>
1131 PassManagerWrapper &PMW, bool Optimized) const {
1132 if (Optimized)
1134 else
1136}
1137
1138/// Find and instantiate the register allocation pass requested by this target
1139/// at the current optimization level. Different register allocators are
1140/// defined as separate passes because they may require different analysis.
1141///
1142/// This helper ensures that the -regalloc-npm= option is always available,
1143/// even for targets that override the default allocator.
1144template <typename Derived, typename TargetMachineT>
1146 PassManagerWrapper &PMW, bool Optimized) const {
1147 // Use the specified -regalloc-npm={basic|greedy|fast|pbqp}
1148 if (Opt.RegAlloc > RegAllocType::Default) {
1149 switch (Opt.RegAlloc) {
1150 case RegAllocType::Fast:
1152 break;
1155 break;
1156 default:
1157 reportFatalUsageError("register allocator not supported yet");
1158 }
1159 return;
1160 }
1161 // -regalloc=default or unspecified, so pick based on the optimization level
1162 // or ask the target for the regalloc pass.
1163 derived().addTargetRegisterAllocator(PMW, Optimized);
1164}
1165
1166template <typename Derived, typename TargetMachineT>
1168 PassManagerWrapper &PMW) const {
1169 // TODO: Ensure allocator is default or fast.
1170 addRegAllocPass(PMW, false);
1171 return Error::success();
1172}
1173
1174template <typename Derived, typename TargetMachineT>
1176 PassManagerWrapper &PMW) const {
1177 // Add the selected register allocation pass.
1178 addRegAllocPass(PMW, true);
1179
1180 // Allow targets to change the register assignments before rewriting.
1181 derived().addPreRewrite(PMW);
1182
1183 // Finally rewrite virtual registers.
1185 // Perform stack slot coloring and post-ra machine LICM.
1186 //
1187 // FIXME: Re-enable coloring with register when it's capable of adding
1188 // kill markers.
1190
1191 return Error::success();
1192}
1193
1194/// Add the minimum set of target-independent passes that are required for
1195/// register allocation. No coalescing or scheduling.
1196template <typename Derived, typename TargetMachineT>
1203
1204/// Add standard target-independent passes that are tightly coupled with
1205/// optimized register allocation, including coalescing, machine instruction
1206/// scheduling, and register allocation itself.
1207template <typename Derived, typename TargetMachineT>
1209 PassManagerWrapper &PMW) const {
1211
1213
1215
1216 // LiveVariables currently requires pure SSA form.
1217 //
1218 // FIXME: Once TwoAddressInstruction pass no longer uses kill flags,
1219 // LiveVariables can be removed completely, and LiveIntervals can be directly
1220 // computed. (We still either need to regenerate kill flags after regalloc, or
1221 // preferably fix the scavenger to not depend on them).
1222 // FIXME: UnreachableMachineBlockElim is a dependant pass of LiveVariables.
1223 // When LiveVariables is removed this has to be removed/moved either.
1224 // Explicit addition of UnreachableMachineBlockElim allows stopping before or
1225 // after it with -stop-before/-stop-after.
1229
1230 // Edge splitting is smarter with machine loop info.
1234
1235 // Eventually, we want to run LiveIntervals before PHI elimination.
1236 if (Opt.EarlyLiveIntervals)
1239
1242
1243 // The machine scheduler may accidentally create disconnected components
1244 // when moving subregister definitions around, avoid this by splitting them to
1245 // separate vregs before. Splitting can also improve reg. allocation quality.
1247
1248 // PreRA instruction scheduling.
1250
1251 if (auto E = derived().addRegAssignmentOptimized(PMW)) {
1252 // addRegAssignmentOptimized did not add a reg alloc pass, so do nothing.
1253 return;
1254 }
1255 // Allow targets to expand pseudo instructions depending on the choice of
1256 // registers before MachineCopyPropagation.
1257 derived().addPostRewrite(PMW);
1258
1259 // Copy propagate to forward register uses and try to eliminate COPYs that
1260 // were not coalesced.
1262
1263 // Run post-ra machine LICM to hoist reloads / remats.
1264 //
1265 // FIXME: can this move into MachineLateOptimization?
1267}
1268
1269//===---------------------------------------------------------------------===//
1270/// Post RegAlloc Pass Configuration
1271//===---------------------------------------------------------------------===//
1272
1273/// Add passes that optimize machine instructions after register allocation.
1274template <typename Derived, typename TargetMachineT>
1276 PassManagerWrapper &PMW) const {
1277 // Branch folding must be run after regalloc and prolog/epilog insertion.
1278 addMachineFunctionPass(BranchFolderPass(Opt.EnableTailMerge), PMW);
1279
1280 // Tail duplication.
1281 // Note that duplicating tail just increases code size and degrades
1282 // performance for targets that require Structured Control Flow.
1283 // In addition it can also make CFG irreducible. Thus we disable it.
1284 if (!TM.requiresStructuredCFG())
1286
1287 // Cleanup of redundant (identical) address/immediate loads.
1289
1290 // Copy propagation.
1292}
1293
1294/// Add standard basic block placement passes.
1295template <typename Derived, typename TargetMachineT>
1297 PassManagerWrapper &PMW) const {
1299 // Run a separate pass to collect block placement statistics.
1300 if (Opt.EnableBlockPlacementStats)
1302}
1303
1304} // namespace llvm
1305
1306#endif // LLVM_PASSES_CODEGENPASSBUILDER_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This is the interface for LLVM's primary stateless and local alias analysis.
This header provides classes for managing passes over SCCs of the call graph.
Analysis containing CSE Info
Definition CSEInfo.cpp:27
Defines an IR pass for CodeGen Prepare.
Analysis that tracks defined/used subregister lanes across COPY instructions and instructions that ge...
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...
static LVOptions Options
Definition LVOptions.cpp:25
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
This pass is required to take advantage of the interprocedural register allocation infrastructure.
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[]
A pass that canonicalizes freeze instructions in a loop.
void addPostRegAlloc(PassManagerWrapper &PMW) const
This method may be implemented by targets that want to run passes after register allocation pass pipe...
void addGlobalMergePass(PassManagerWrapper &PMW) const
Target can override this to add GlobalMergePass before all IR passes.
void addModulePass(PassT &&Pass, PassManagerWrapper &PMW, bool Force=false, StringRef Name=PassT::name()) const
decltype(std::declval< PassT & >().run( std::declval< Function & >(), std::declval< FunctionAnalysisManager & >())) is_function_pass_t
void flushFPMsToMPM(PassManagerWrapper &PMW, bool FreeMachineFunctions=false) const
void addPreGlobalInstructionSelect(PassManagerWrapper &PMW) const
This method may be implemented by targets that want to run passes immediately before the (global) ins...
Error addRegAssignmentFast(PassManagerWrapper &PMW) const
Add core register alloator passes which do the actual register assignment and rewriting.
void requireCGSCCOrder(PassManagerWrapper &PMW) const
void addISelPrepare(PassManagerWrapper &PMW) const
Add common passes that perform LLVM IR to IR transforms in preparation for instruction selection.
void addTargetRegisterAllocator(PassManagerWrapper &PMW, bool Optimized) const
Utilities for targets to add passes to the pass manager.
bool isGlobalISelAbortEnabled() const
Check whether or not GlobalISel should abort on error.
Error addMachinePasses(PassManagerWrapper &PMW) const
Add the complete, standard set of LLVM CodeGen passes.
Error addRegAssignmentOptimized(PassManagerWrapper &PMWM) const
void insertPass(InsertedPassT &&Pass) const
Insert InsertedPass pass after TargetPass pass.
void addPreRewrite(PassManagerWrapper &PMW) const
addPreRewrite - Add passes to the optimized register allocation pipeline after register allocation is...
Error addFastRegAlloc(PassManagerWrapper &PMW) const
addFastRegAlloc - Add the minimum set of target-independent passes that are required for fast registe...
Error buildPipeline(ModulePassManager &MPM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType) const
void addPreISel(PassManagerWrapper &PMW) const
{{@ For GlobalISel
Error addCoreISelPasses(PassManagerWrapper &PMW) const
Add the actual instruction selection passes.
void stopAddingInCGSCCOrder(PassManagerWrapper &PMW) const
std::function< Expected< std::unique_ptr< MCStreamer > >(MCContext &)> CreateMCStreamer
void addPreLegalizeMachineIR(PassManagerWrapper &PMW) const
This method may be implemented by targets that want to run passes immediately before legalization.
void addCodeGenPrepare(PassManagerWrapper &PMW) const
Add pass to prepare the LLVM IR for code generation.
void addPreEmitPass(PassManagerWrapper &PMW) const
This pass may be implemented by targets that want to run passes immediately before machine code is em...
void addMachineSSAOptimization(PassManagerWrapper &PMW) const
Methods with trivial inline returns are convenient points in the common codegen pass pipeline where t...
void addIRPasses(PassManagerWrapper &PMW) const
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
decltype(std::declval< PassT & >().run( std::declval< MachineFunction & >(), std::declval< MachineFunctionAnalysisManager & >())) is_machine_function_pass_t
void addMachineLateOptimization(PassManagerWrapper &PMW) const
Add passes that optimize machine instructions after register allocation.
Error addLegalizeMachineIR(PassManagerWrapper &PMW) const
This method should install a legalize pass, which converts the instruction sequence into one that can...
CodeGenPassBuilder(TargetMachineT &TM, const CGPassBuilderOption &Opts, PassInstrumentationCallbacks *PIC)
void addPreEmitPass2(PassManagerWrapper &PMW) const
Targets may add passes immediately before machine code is emitted in this callback.
void addOptimizedRegAlloc(PassManagerWrapper &PMW) const
addOptimizedRegAlloc - Add passes related to register allocation.
Error addIRTranslator(PassManagerWrapper &PMW) const
This method should install an IR translator pass, which converts from LLVM code to machine instructio...
void addGCPasses(PassManagerWrapper &PMW) const
addGCPasses - Add late codegen passes that analyze code for garbage collection.
void addRegAllocPass(PassManagerWrapper &PMW, bool Optimized) const
addMachinePasses helper to create the target-selected or overriden regalloc pass.
Error addRegBankSelect(PassManagerWrapper &PMW) const
This method should install a register bank selector pass, which assigns register banks to virtual reg...
void addMachineFunctionPass(PassT &&Pass, PassManagerWrapper &PMW, bool Force=false, StringRef Name=PassT::name()) const
void addISelPasses(PassManagerWrapper &PMW) const
High level function that adds all passes necessary to go from llvm IR representation to the MI repres...
void disablePass()
Allow the target to disable a specific pass by default.
Error addInstSelector(PassManagerWrapper &PMW) const
addInstSelector - This method should install an instruction selector pass, which converts from LLVM c...
void addPreRegAlloc(PassManagerWrapper &PMW) const
This method may be implemented by targets that want to run passes immediately before register allocat...
void addPassesToHandleExceptions(PassManagerWrapper &PMW) const
Add passes to lower exception handling for the code generator.
void addBlockPlacement(PassManagerWrapper &PMW) const
Add standard basic block placement passes.
void addPreRegBankSelect(PassManagerWrapper &PMW) const
This method may be implemented by targets that want to run passes immediately before the register ban...
void addPreSched2(PassManagerWrapper &PMW) const
This method may be implemented by targets that want to run passes after prolog-epilog insertion and b...
Error addGlobalInstructionSelect(PassManagerWrapper &PMWM) const
This method should install a (global) instruction selector pass, which converts possibly generic inst...
void addFunctionPass(PassT &&Pass, PassManagerWrapper &PMW, bool Force=false, StringRef Name=PassT::name()) const
void addILPOpts(PassManagerWrapper &PMW) const
Add passes that optimize instruction level parallelism for out-of-order targets.
decltype(std::declval< PassT & >().run( std::declval< Module & >(), std::declval< ModuleAnalysisManager & >())) is_module_pass_t
void addPostRewrite(PassManagerWrapper &PMW) const
Add passes to be run immediately after virtual registers are rewritten to physical registers.
void addAsmPrinter(PassManagerWrapper &PMW, CreateMCStreamer) const
PassInstrumentationCallbacks * getPassInstrumentationCallbacks() const
bool reportDiagnosticWhenGlobalISelFallback() const
Check whether or not a diagnostic should be emitted when GlobalISel uses the fallback path.
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
static ErrorSuccess success()
Create a success value.
Definition Error.h:336
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:229
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:64
ExceptionHandling getExceptionHandlingType() const
Definition MCAsmInfo.h:633
Context object for machine code objects.
Definition MCContext.h:83
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
LLVM_ABI StringRef getPassNameForClassName(StringRef ClassName)
Get the pass name for a given pass class name. Empty if no match found.
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!std::is_same_v< PassT, PassManager > > addPass(PassT &&Pass)
bool isEmpty() const
Returns if the pass manager contains any passes.
Pass interface - Implemented by all 'passes'.
Definition Pass.h:99
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...
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
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:134
An abstract base class for streams implementations that also support a pwrite operation.
#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.
ModuleToFunctionPassAdaptor createModuleToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition Error.cpp:98
@ SjLj
setjmp/longjmp based exceptions
Definition CodeGen.h:56
@ ZOS
z/OS MVS Exception Handling.
Definition CodeGen.h:61
@ None
No exception support.
Definition CodeGen.h:54
@ AIX
AIX Exception Handling.
Definition CodeGen.h:60
@ DwarfCFI
DWARF-like instruction based exceptions.
Definition CodeGen.h:55
@ WinEH
Windows Exception Handling.
Definition CodeGen.h:58
@ Wasm
WebAssembly Exception Handling.
Definition CodeGen.h:59
PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & > LoopPassManager
The Loop pass manager.
ModuleToPostOrderCGSCCPassAdaptor createModuleToPostOrderCGSCCPassAdaptor(CGSCCPassT &&Pass)
A function to deduce a function pass type and wrap it in the templated adaptor.
FunctionToLoopPassAdaptor createFunctionToLoopPassAdaptor(LoopPassT &&Pass, bool UseMemorySSA=false)
A function to deduce a loop pass type and wrap it in the templated adaptor.
CGSCCToFunctionPassAdaptor createCGSCCToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false, bool NoRerun=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
Definition CodeGen.h:111
FunctionToMachineFunctionPassAdaptor createFunctionToMachineFunctionPassAdaptor(MachineFunctionPassT &&Pass)
PassManager< Module > ModulePassManager
Convenience typedef for a pass manager over modules.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:207
FunctionAddr VTableAddr Count
Definition InstrProf.h:139
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:82
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
Definition Error.h:340
PassManager< Function > FunctionPassManager
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'.
PassManager< MachineFunction > MachineFunctionPassManager
Convenience typedef for a pass manager over functions.
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
Definition Error.cpp:180
Global function merging pass for new pass manager.
A utility pass template to force an analysis result to be available.