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"
68#include "llvm/CodeGen/PEI.h"
105#include "llvm/IR/PassManager.h"
106#include "llvm/IR/Verifier.h"
108#include "llvm/MC/MCAsmInfo.h"
110#include "llvm/Support/CodeGen.h"
111#include "llvm/Support/Debug.h"
112#include "llvm/Support/Error.h"
129#include <cassert>
130#include <utility>
131
132namespace llvm {
133
134// FIXME: Dummy target independent passes definitions that have not yet been
135// ported to new pass manager. Once they do, remove these.
136#define DUMMY_FUNCTION_PASS(NAME, PASS_NAME) \
137 struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
138 template <typename... Ts> PASS_NAME(Ts &&...) {} \
139 PreservedAnalyses run(Function &, FunctionAnalysisManager &) { \
140 return PreservedAnalyses::all(); \
141 } \
142 };
143#define DUMMY_MACHINE_MODULE_PASS(NAME, PASS_NAME) \
144 struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
145 template <typename... Ts> PASS_NAME(Ts &&...) {} \
146 PreservedAnalyses run(Module &, ModuleAnalysisManager &) { \
147 return PreservedAnalyses::all(); \
148 } \
149 };
150#define DUMMY_MACHINE_FUNCTION_PASS(NAME, PASS_NAME) \
151 struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
152 template <typename... Ts> PASS_NAME(Ts &&...) {} \
153 PreservedAnalyses run(MachineFunction &, \
154 MachineFunctionAnalysisManager &) { \
155 return PreservedAnalyses::all(); \
156 } \
157 };
158#include "llvm/Passes/MachinePassRegistry.def"
159
160class PassManagerWrapper {
161private:
162 PassManagerWrapper(ModulePassManager &ModulePM) : MPM(ModulePM) {};
163
167
168 template <typename DerivedT, typename TargetMachineT>
169 friend class CodeGenPassBuilder;
170};
171
172/// This class provides access to building LLVM's passes.
173///
174/// Its members provide the baseline state available to passes during their
175/// construction. The \c MachinePassRegistry.def file specifies how to construct
176/// all of the built-in passes, and those may reference these members during
177/// construction.
178template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
179public:
180 explicit CodeGenPassBuilder(TargetMachineT &TM,
181 const CGPassBuilderOption &Opts,
183 : TM(TM), Opt(Opts), PIC(PIC) {
184 // Target could set CGPassBuilderOption::MISchedPostRA to true to achieve
185 // substitutePass(&PostRASchedulerID, &PostMachineSchedulerID)
186
187 // Target should override TM.Options.EnableIPRA in their target-specific
188 // LLVMTM ctor. See TargetMachine::setGlobalISel for example.
189 if (Opt.EnableIPRA) {
190 TM.Options.EnableIPRA = *Opt.EnableIPRA;
191 } else {
192 // If not explicitly specified, use target default.
193 TM.Options.EnableIPRA |= TM.useIPRA();
194 }
195
196 if (Opt.EnableGlobalISelAbort)
197 TM.Options.GlobalISelAbort = *Opt.EnableGlobalISelAbort;
198
199 if (!Opt.OptimizeRegAlloc)
200 Opt.OptimizeRegAlloc = getOptLevel() != CodeGenOptLevel::None;
201 }
202
204 raw_pwrite_stream *DwoOut,
205 CodeGenFileType FileType) const;
206
210
211protected:
212 template <typename PassT>
213 using is_module_pass_t = decltype(std::declval<PassT &>().run(
214 std::declval<Module &>(), std::declval<ModuleAnalysisManager &>()));
215
216 template <typename PassT>
217 using is_function_pass_t = decltype(std::declval<PassT &>().run(
218 std::declval<Function &>(), std::declval<FunctionAnalysisManager &>()));
219
220 template <typename PassT>
221 using is_machine_function_pass_t = decltype(std::declval<PassT &>().run(
222 std::declval<MachineFunction &>(),
223 std::declval<MachineFunctionAnalysisManager &>()));
224
225 template <typename PassT>
227 bool Force = false,
228 StringRef Name = PassT::name()) const {
230 "Only function passes are supported.");
231 if (!Force && !runBeforeAdding(Name))
232 return;
233 PMW.FPM.addPass(std::forward<PassT>(Pass));
234 }
235
236 template <typename PassT>
237 void addModulePass(PassT &&Pass, PassManagerWrapper &PMW, bool Force = false,
238 StringRef Name = PassT::name()) const {
240 "Only module passes are suported.");
241 assert(PMW.FPM.isEmpty() && PMW.MFPM.isEmpty() &&
242 "You cannot insert a module pass without first flushing the current "
243 "function pipelines to the module pipeline.");
244 if (!Force && !runBeforeAdding(Name))
245 return;
246 PMW.MPM.addPass(std::forward<PassT>(Pass));
247 }
248
249 template <typename PassT>
251 bool Force = false,
252 StringRef Name = PassT::name()) const {
254 "Only machine function passes are supported.");
255
256 if (!Force && !runBeforeAdding(Name))
257 return;
258 PMW.MFPM.addPass(std::forward<PassT>(Pass));
259 for (auto &C : AfterCallbacks)
260 C(Name, PMW.MFPM);
261 }
262
264 bool FreeMachineFunctions = false) const {
265 if (PMW.FPM.isEmpty() && PMW.MFPM.isEmpty())
266 return;
267 if (!PMW.MFPM.isEmpty()) {
268 PMW.FPM.addPass(
269 createFunctionToMachineFunctionPassAdaptor(std::move(PMW.MFPM)));
270 PMW.MFPM = MachineFunctionPassManager();
271 }
272 if (FreeMachineFunctions)
274 if (AddInCGSCCOrder) {
276 createCGSCCToFunctionPassAdaptor(std::move(PMW.FPM))));
277 } else {
278 PMW.MPM.addPass(createModuleToFunctionPassAdaptor(std::move(PMW.FPM)));
279 }
280 PMW.FPM = FunctionPassManager();
281 }
282
284 assert(!AddInCGSCCOrder);
285 flushFPMsToMPM(PMW);
286 AddInCGSCCOrder = true;
287 }
289 assert(AddInCGSCCOrder);
290 flushFPMsToMPM(PMW);
291 AddInCGSCCOrder = false;
292 }
293
294 TargetMachineT &TM;
297
298 template <typename TMC> TMC &getTM() const { return static_cast<TMC &>(TM); }
299 CodeGenOptLevel getOptLevel() const { return TM.getOptLevel(); }
300
301 /// Check whether or not GlobalISel should abort on error.
302 /// When this is disabled, GlobalISel will fall back on SDISel instead of
303 /// erroring out.
305 return TM.Options.GlobalISelAbort == GlobalISelAbortMode::Enable;
306 }
307
308 /// Check whether or not a diagnostic should be emitted when GlobalISel
309 /// uses the fallback path. In other words, it will emit a diagnostic
310 /// when GlobalISel failed and isGlobalISelAbortEnabled is false.
312 return TM.Options.GlobalISelAbort == GlobalISelAbortMode::DisableWithDiag;
313 }
314
315 /// addInstSelector - This method should install an instruction selector pass,
316 /// which converts from LLVM code to machine instructions.
318 return make_error<StringError>("addInstSelector is not overridden",
320 }
321
322 /// Target can override this to add GlobalMergePass before all IR passes.
324
325 /// Add passes that optimize instruction level parallelism for out-of-order
326 /// targets. These passes are run while the machine code is still in SSA
327 /// form, so they can use MachineTraceMetrics to control their heuristics.
328 ///
329 /// All passes added here should preserve the MachineDominatorTree,
330 /// MachineLoopInfo, and MachineTraceMetrics analyses.
331 void addILPOpts(PassManagerWrapper &PMW) const {}
332
333 /// This method may be implemented by targets that want to run passes
334 /// immediately before register allocation.
336
337 /// addPreRewrite - Add passes to the optimized register allocation pipeline
338 /// after register allocation is complete, but before virtual registers are
339 /// rewritten to physical registers.
340 ///
341 /// These passes must preserve VirtRegMap and LiveIntervals, and when running
342 /// after RABasic or RAGreedy, they should take advantage of LiveRegMatrix.
343 /// When these passes run, VirtRegMap contains legal physreg assignments for
344 /// all virtual registers.
345 ///
346 /// Note if the target overloads addRegAssignAndRewriteOptimized, this may not
347 /// be honored. This is also not generally used for the fast variant,
348 /// where the allocation and rewriting are done in one pass.
350
351 /// Add passes to be run immediately after virtual registers are rewritten
352 /// to physical registers.
354
355 /// This method may be implemented by targets that want to run passes after
356 /// register allocation pass pipeline but before prolog-epilog insertion.
358
359 /// This method may be implemented by targets that want to run passes after
360 /// prolog-epilog insertion and before the second instruction scheduling pass.
362
363 /// This pass may be implemented by targets that want to run passes
364 /// immediately before machine code is emitted.
366
367 /// Targets may add passes immediately before machine code is emitted in this
368 /// callback. This is called even later than `addPreEmitPass`.
369 // FIXME: Rename `addPreEmitPass` to something more sensible given its actual
370 // position and remove the `2` suffix here as this callback is what
371 // `addPreEmitPass` *should* be but in reality isn't.
373
374 /// {{@ For GlobalISel
375 ///
376
377 /// addPreISel - This method should add any "last minute" LLVM->LLVM
378 /// passes (which are run just before instruction selector).
380 llvm_unreachable("addPreISel is not overridden");
381 }
382
383 /// This method should install an IR translator pass, which converts from
384 /// LLVM code to machine instructions with possibly generic opcodes.
386 return make_error<StringError>("addIRTranslator is not overridden",
388 }
389
390 /// This method may be implemented by targets that want to run passes
391 /// immediately before legalization.
393
394 /// This method should install a legalize pass, which converts the instruction
395 /// sequence into one that can be selected by the target.
397 return make_error<StringError>("addLegalizeMachineIR is not overridden",
399 }
400
401 /// This method may be implemented by targets that want to run passes
402 /// immediately before the register bank selection.
404
405 /// This method should install a register bank selector pass, which
406 /// assigns register banks to virtual registers without a register
407 /// class or register banks.
409 return make_error<StringError>("addRegBankSelect is not overridden",
411 }
412
413 /// This method may be implemented by targets that want to run passes
414 /// immediately before the (global) instruction selection.
416
417 /// This method should install a (global) instruction selector pass, which
418 /// converts possibly generic instructions to fully target-specific
419 /// instructions, thereby constraining all generic virtual registers to
420 /// register classes.
423 "addGlobalInstructionSelect is not overridden",
425 }
426 /// @}}
427
428 /// High level function that adds all passes necessary to go from llvm IR
429 /// representation to the MI representation.
430 /// Adds IR based lowering and target specific optimization passes and finally
431 /// the core instruction selection passes.
433
434 /// Add the actual instruction selection passes. This does not include
435 /// preparation passes on IR.
437
438 /// Add the complete, standard set of LLVM CodeGen passes.
439 /// Fully developed targets will not generally override this.
441
442 /// Add passes to lower exception handling for the code generator.
444
445 /// Add common target configurable passes that perform LLVM IR to IR
446 /// transforms following machine independent optimization.
448
449 /// Add pass to prepare the LLVM IR for code generation. This should be done
450 /// before exception handling preparation passes.
452
453 /// Add common passes that perform LLVM IR to IR transforms in preparation for
454 /// instruction selection.
456
457 /// Methods with trivial inline returns are convenient points in the common
458 /// codegen pass pipeline where targets may insert passes. Methods with
459 /// out-of-line standard implementations are major CodeGen stages called by
460 /// addMachinePasses. Some targets may override major stages when inserting
461 /// passes is insufficient, but maintaining overriden stages is more work.
462 ///
463
464 /// addMachineSSAOptimization - Add standard passes that optimize machine
465 /// instructions in SSA form.
467
468 /// addFastRegAlloc - Add the minimum set of target-independent passes that
469 /// are required for fast register allocation.
471
472 /// addOptimizedRegAlloc - Add passes related to register allocation.
473 /// CodeGenTargetMachineImpl provides standard regalloc passes for most
474 /// targets.
476
477 /// Add passes that optimize machine instructions after register allocation.
479
480 /// addGCPasses - Add late codegen passes that analyze code for garbage
481 /// collection. This should return true if GC info should be printed after
482 /// these passes.
483 void addGCPasses(PassManagerWrapper &PMW) const {}
484
485 /// Add standard basic block placement passes.
487
489 std::function<Expected<std::unique_ptr<MCStreamer>>(MCContext &)>;
491 llvm_unreachable("addAsmPrinter is not overridden");
492 }
493
494 /// Utilities for targets to add passes to the pass manager.
495 ///
496
497 /// createTargetRegisterAllocator - Create the register allocator pass for
498 /// this target at the current optimization level.
500 bool Optimized) const;
501
502 /// addMachinePasses helper to create the target-selected or overriden
503 /// regalloc pass.
504 void addRegAllocPass(PassManagerWrapper &PMW, bool Optimized) const;
505
506 /// Add core register alloator passes which do the actual register assignment
507 /// and rewriting. \returns true if any passes were added.
510
511 /// Allow the target to disable a specific pass by default.
512 /// Backend can declare unwanted passes in constructor.
513 template <typename... PassTs> void disablePass() {
514 BeforeCallbacks.emplace_back(
515 [](StringRef Name) { return ((Name != PassTs::name()) && ...); });
516 }
517
518 /// Insert InsertedPass pass after TargetPass pass.
519 /// Only machine function passes are supported.
520 template <typename TargetPassT, typename InsertedPassT>
521 void insertPass(InsertedPassT &&Pass) const {
522 AfterCallbacks.emplace_back(
523 [&](StringRef Name, MachineFunctionPassManager &MFPM) mutable {
524 if (Name == TargetPassT::name() &&
525 runBeforeAdding(InsertedPassT::name())) {
526 MFPM.addPass(std::forward<InsertedPassT>(Pass));
527 }
528 });
529 }
530
531private:
532 DerivedT &derived() { return static_cast<DerivedT &>(*this); }
533 const DerivedT &derived() const {
534 return static_cast<const DerivedT &>(*this);
535 }
536
537 bool runBeforeAdding(StringRef Name) const {
538 bool ShouldAdd = true;
539 for (auto &C : BeforeCallbacks)
540 ShouldAdd &= C(Name);
541 return ShouldAdd;
542 }
543
544 void setStartStopPasses(const TargetPassConfig::StartStopInfo &Info) const;
545
546 Error verifyStartStop(const TargetPassConfig::StartStopInfo &Info) const;
547
548 mutable SmallVector<llvm::unique_function<bool(StringRef)>, 4>
549 BeforeCallbacks;
550 mutable SmallVector<
551 llvm::unique_function<void(StringRef, MachineFunctionPassManager &)>, 4>
552 AfterCallbacks;
553
554 /// Helper variable for `-start-before/-start-after/-stop-before/-stop-after`
555 mutable bool Started = true;
556 mutable bool Stopped = true;
557 mutable bool AddInCGSCCOrder = false;
558};
559
560template <typename Derived, typename TargetMachineT>
563 CodeGenFileType FileType) const {
564 auto StartStopInfo = TargetPassConfig::getStartStopInfo(*PIC);
565 if (!StartStopInfo)
566 return StartStopInfo.takeError();
567 setStartStopPasses(*StartStopInfo);
568
570 bool PrintMIR = !PrintAsm && FileType != CodeGenFileType::Null;
571
572 PassManagerWrapper PMW(MPM);
573
575 /*Force=*/true);
577 /*Force=*/true);
579 /*Force=*/true);
581 /*Force=*/true);
582 addISelPasses(PMW);
583 flushFPMsToMPM(PMW);
584
585 if (PrintMIR)
586 addModulePass(PrintMIRPreparePass(Out), PMW, /*Force=*/true);
587
588 if (auto Err = addCoreISelPasses(PMW))
589 return std::move(Err);
590
591 if (auto Err = derived().addMachinePasses(PMW))
592 return std::move(Err);
593
594 if (!Opt.DisableVerify)
596
597 if (PrintAsm) {
598 derived().addAsmPrinter(
599 PMW, [this, &Out, DwoOut, FileType](MCContext &Ctx) {
600 return this->TM.createMCStreamer(Out, DwoOut, FileType, Ctx);
601 });
602 }
603
604 if (PrintMIR)
605 addMachineFunctionPass(PrintMIRPass(Out), PMW, /*Force=*/true);
606
607 flushFPMsToMPM(PMW, /*FreeMachineFunctions=*/true);
608
609 return verifyStartStop(*StartStopInfo);
610}
611
612template <typename Derived, typename TargetMachineT>
613void CodeGenPassBuilder<Derived, TargetMachineT>::setStartStopPasses(
614 const TargetPassConfig::StartStopInfo &Info) const {
615 if (!Info.StartPass.empty()) {
616 Started = false;
617 BeforeCallbacks.emplace_back([this, &Info, AfterFlag = Info.StartAfter,
618 Count = 0u](StringRef ClassName) mutable {
619 if (Count == Info.StartInstanceNum) {
620 if (AfterFlag) {
621 AfterFlag = false;
622 Started = true;
623 }
624 return Started;
625 }
626
627 auto PassName = PIC->getPassNameForClassName(ClassName);
628 if (Info.StartPass == PassName && ++Count == Info.StartInstanceNum)
629 Started = !Info.StartAfter;
630
631 return Started;
632 });
633 }
634
635 if (!Info.StopPass.empty()) {
636 Stopped = false;
637 BeforeCallbacks.emplace_back([this, &Info, AfterFlag = Info.StopAfter,
638 Count = 0u](StringRef ClassName) mutable {
639 if (Count == Info.StopInstanceNum) {
640 if (AfterFlag) {
641 AfterFlag = false;
642 Stopped = true;
643 }
644 return !Stopped;
645 }
646
647 auto PassName = PIC->getPassNameForClassName(ClassName);
648 if (Info.StopPass == PassName && ++Count == Info.StopInstanceNum)
649 Stopped = !Info.StopAfter;
650 return !Stopped;
651 });
652 }
653}
654
655template <typename Derived, typename TargetMachineT>
656Error CodeGenPassBuilder<Derived, TargetMachineT>::verifyStartStop(
658 if (Started && Stopped)
659 return Error::success();
660
661 if (!Started)
663 "Can't find start pass \"" + Info.StartPass + "\".",
664 std::make_error_code(std::errc::invalid_argument));
665 if (!Stopped)
667 "Can't find stop pass \"" + Info.StopPass + "\".",
668 std::make_error_code(std::errc::invalid_argument));
669 return Error::success();
670}
671
672template <typename Derived, typename TargetMachineT>
674 PassManagerWrapper &PMW) const {
675 derived().addGlobalMergePass(PMW);
676 if (TM.useEmulatedTLS())
678
681
682 derived().addIRPasses(PMW);
683 derived().addCodeGenPrepare(PMW);
685 derived().addISelPrepare(PMW);
686}
687
688/// Add common target configurable passes that perform LLVM IR to IR transforms
689/// following machine independent optimization.
690template <typename Derived, typename TargetMachineT>
692 PassManagerWrapper &PMW) const {
693 // Before running any passes, run the verifier to determine if the input
694 // coming from the front-end and/or optimizer is valid.
695 if (!Opt.DisableVerify)
696 addFunctionPass(VerifierPass(), PMW, /*Force=*/true);
697
698 // Run loop strength reduction before anything else.
699 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableLSR) {
700 LoopPassManager LPM;
701 LPM.addPass(CanonicalizeFreezeInLoopsPass());
702 LPM.addPass(LoopStrengthReducePass());
703 if (Opt.EnableLoopTermFold)
704 LPM.addPass(LoopTermFoldPass());
706 /*UseMemorySSA=*/true),
707 PMW);
708 }
709
711 // The MergeICmpsPass tries to create memcmp calls by grouping sequences of
712 // loads and compares. ExpandMemCmpPass then tries to expand those calls
713 // into optimally-sized loads and compares. The transforms are enabled by a
714 // target lowering hook.
715 if (!Opt.DisableMergeICmps)
718 }
719
720 // Run GC lowering passes for builtin collectors
721 // TODO: add a pass insertion point here
723 // Explicitly check to see if we should add ShadowStackGCLowering to avoid
724 // splitting the function pipeline if we do not have to.
725 if (runBeforeAdding(ShadowStackGCLoweringPass::name())) {
726 flushFPMsToMPM(PMW);
728 }
730
731 // Make sure that no unreachable blocks are instruction selected.
733
734 // Prepare expensive constants for SelectionDAG.
735 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableConstantHoisting)
737
738 // Replace calls to LLVM intrinsics (e.g., exp, log) operating on vector
739 // operands with calls to the corresponding functions in a vector library.
742
744 !Opt.DisablePartialLibcallInlining)
746
747 // Instrument function entry and exit, e.g. with calls to mcount().
748 addFunctionPass(EntryExitInstrumenterPass(/*PostInlining=*/true), PMW);
749
750 // Add scalarization of target's unsupported masked memory intrinsics pass.
751 // the unsupported intrinsic will be replaced with a chain of basic blocks,
752 // that stores/loads element one-by-one if the appropriate mask bit is set.
754
755 // Expand reduction intrinsics into shuffle sequences if the target wants to.
756 if (!Opt.DisableExpandReductions)
758
759 // Convert conditional moves to conditional jumps when profitable.
760 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableSelectOptimize)
762
763 if (Opt.EnableGlobalMergeFunc) {
764 flushFPMsToMPM(PMW);
766 }
767}
768
769/// Turn exception handling constructs into something the code generators can
770/// handle.
771template <typename Derived, typename TargetMachineT>
773 PassManagerWrapper &PMW) const {
774 const MCAsmInfo *MCAI = TM.getMCAsmInfo();
775 assert(MCAI && "No MCAsmInfo");
776 switch (MCAI->getExceptionHandlingType()) {
778 // SjLj piggy-backs on dwarf for this bit. The cleanups done apply to both
779 // Dwarf EH prepare needs to be run after SjLj prepare. Otherwise,
780 // catch info can get misplaced when a selector ends up more than one block
781 // removed from the parent invoke(s). This could happen when a landing
782 // pad is shared by multiple invokes and is also a target of a normal
783 // edge from elsewhere.
785 [[fallthrough]];
791 break;
793 // We support using both GCC-style and MSVC-style exceptions on Windows, so
794 // add both preparation passes. Each pass will only actually run if it
795 // recognizes the personality function.
798 break;
800 // Wasm EH uses Windows EH instructions, but it does not need to demote PHIs
801 // on catchpads and cleanuppads because it does not outline them into
802 // funclets. Catchswitch blocks are not lowered in SelectionDAG, so we
803 // should remove PHIs there.
804 addFunctionPass(WinEHPreparePass(/*DemoteCatchSwitchPHIOnly=*/false), PMW);
806 break;
809
810 // The lower invoke pass may create unreachable code. Remove it.
812 break;
813 }
814}
815
816/// Add pass to prepare the LLVM IR for code generation. This should be done
817/// before exception handling preparation passes.
818template <typename Derived, typename TargetMachineT>
820 PassManagerWrapper &PMW) const {
821 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableCGP)
823 // TODO: Default ctor'd RewriteSymbolPass is no-op.
824 // addPass(RewriteSymbolPass());
825}
826
827/// Add common passes that perform LLVM IR to IR transforms in preparation for
828/// instruction selection.
829template <typename Derived, typename TargetMachineT>
831 PassManagerWrapper &PMW) const {
832 derived().addPreISel(PMW);
833
834 if (Opt.RequiresCodeGenSCCOrder && !AddInCGSCCOrder)
836
839
841 // Add both the safe stack and the stack protection passes: each of them will
842 // only protect functions that have corresponding attributes.
845
846 if (Opt.PrintISelInput)
848 dbgs(), "\n\n*** Final LLVM Code input to ISel ***\n"),
849 PMW);
850
851 // All passes which modify the LLVM IR are now complete; run the verifier
852 // to ensure that the IR is valid.
853 if (!Opt.DisableVerify)
854 addFunctionPass(VerifierPass(), PMW, /*Force=*/true);
855}
856
857template <typename Derived, typename TargetMachineT>
859 PassManagerWrapper &PMW) const {
860 // Enable FastISel with -fast-isel, but allow that to be overridden.
861 TM.setO0WantsFastISel(Opt.EnableFastISelOption.value_or(true));
862
863 // Determine an instruction selector.
864 enum class SelectorType { SelectionDAG, FastISel, GlobalISel };
865 SelectorType Selector;
866
867 if (Opt.EnableFastISelOption && *Opt.EnableFastISelOption == true)
868 Selector = SelectorType::FastISel;
869 else if ((Opt.EnableGlobalISelOption &&
870 *Opt.EnableGlobalISelOption == true) ||
871 (TM.Options.EnableGlobalISel &&
872 (!Opt.EnableGlobalISelOption ||
873 *Opt.EnableGlobalISelOption == false)))
874 Selector = SelectorType::GlobalISel;
875 else if (TM.getOptLevel() == CodeGenOptLevel::None && TM.getO0WantsFastISel())
876 Selector = SelectorType::FastISel;
877 else
878 Selector = SelectorType::SelectionDAG;
879
880 // Set consistently TM.Options.EnableFastISel and EnableGlobalISel.
881 if (Selector == SelectorType::FastISel) {
882 TM.setFastISel(true);
883 TM.setGlobalISel(false);
884 } else if (Selector == SelectorType::GlobalISel) {
885 TM.setFastISel(false);
886 TM.setGlobalISel(true);
887 }
888
889 // Add instruction selector passes.
890 if (Selector == SelectorType::GlobalISel) {
891 if (auto Err = derived().addIRTranslator(PMW))
892 return std::move(Err);
893
894 derived().addPreLegalizeMachineIR(PMW);
895
896 if (auto Err = derived().addLegalizeMachineIR(PMW))
897 return std::move(Err);
898
899 // Before running the register bank selector, ask the target if it
900 // wants to run some passes.
901 derived().addPreRegBankSelect(PMW);
902
903 if (auto Err = derived().addRegBankSelect(PMW))
904 return std::move(Err);
905
906 derived().addPreGlobalInstructionSelect(PMW);
907
908 if (auto Err = derived().addGlobalInstructionSelect(PMW))
909 return std::move(Err);
910
911 // Pass to reset the MachineFunction if the ISel failed.
913 ResetMachineFunctionPass(reportDiagnosticWhenGlobalISelFallback(),
915 PMW);
916
917 // Provide a fallback path when we do not want to abort on
918 // not-yet-supported input.
920 if (auto Err = derived().addInstSelector(PMW))
921 return std::move(Err);
922
923 } else if (auto Err = derived().addInstSelector(PMW))
924 return std::move(Err);
925
926 // Expand pseudo-instructions emitted by ISel. Don't run the verifier before
927 // FinalizeISel.
929
930 // // Print the instruction selected machine code...
931 // printAndVerify("After Instruction Selection");
932
933 return Error::success();
934}
935
936/// Add the complete set of target-independent postISel code generator passes.
937///
938/// This can be read as the standard order of major LLVM CodeGen stages. Stages
939/// with nontrivial configuration or multiple passes are broken out below in
940/// add%Stage routines.
941///
942/// Any CodeGenPassBuilder<Derived, TargetMachine>::addXX routine may be
943/// overriden by the Target. The addPre/Post methods with empty header
944/// implementations allow injecting target-specific fixups just before or after
945/// major stages. Additionally, targets have the flexibility to change pass
946/// order within a stage by overriding default implementation of add%Stage
947/// routines below. Each technique has maintainability tradeoffs because
948/// alternate pass orders are not well supported. addPre/Post works better if
949/// the target pass is easily tied to a common pass. But if it has subtle
950/// dependencies on multiple passes, the target should override the stage
951/// instead.
952template <typename Derived, typename TargetMachineT>
954 PassManagerWrapper &PMW) const {
955 // Add passes that optimize machine instructions in SSA form.
957 derived().addMachineSSAOptimization(PMW);
958 } else {
959 // If the target requests it, assign local variables to stack slots relative
960 // to one another and simplify frame index references where possible.
962 }
963
964 if (TM.Options.EnableIPRA) {
965 flushFPMsToMPM(PMW);
967 PMW);
969 }
970 // Run pre-ra passes.
971 derived().addPreRegAlloc(PMW);
972
973 // Run register allocation and passes that are tightly coupled with it,
974 // including phi elimination and scheduling.
975 if (*Opt.OptimizeRegAlloc) {
976 derived().addOptimizedRegAlloc(PMW);
977 } else {
978 if (auto Err = derived().addFastRegAlloc(PMW))
979 return Err;
980 }
981
982 // Run post-ra passes.
983 derived().addPostRegAlloc(PMW);
984
987
988 // Insert prolog/epilog code. Eliminate abstract frame index references...
992 }
993
995
996 /// Add passes that optimize machine instructions after register allocation.
998 derived().addMachineLateOptimization(PMW);
999
1000 // Expand pseudo instructions before second scheduling pass.
1002
1003 // Run pre-sched2 passes.
1004 derived().addPreSched2(PMW);
1005
1006 if (Opt.EnableImplicitNullChecks)
1007 addMachineFunctionPass(ImplicitNullChecksPass(), PMW);
1008
1009 // Second pass scheduler.
1010 // Let Target optionally insert this pass by itself at some other
1011 // point.
1013 !TM.targetSchedulesPostRAScheduling()) {
1014 if (Opt.MISchedPostRA)
1016 else
1018 }
1019
1020 // GC
1021 derived().addGCPasses(PMW);
1022
1023 // Basic block placement.
1025 derived().addBlockPlacement(PMW);
1026
1027 // Insert before XRay Instrumentation.
1029
1032
1033 derived().addPreEmitPass(PMW);
1034
1035 if (TM.Options.EnableIPRA) {
1036 // Collect register usage information and produce a register mask of
1037 // clobbered registers, to be used to optimize call sites.
1038 flushFPMsToMPM(PMW);
1040 PMW);
1042 }
1043
1044 addMachineFunctionPass(FuncletLayoutPass(), PMW);
1045
1047 addMachineFunctionPass(StackMapLivenessPass(), PMW);
1050 getTM<TargetMachine>().Options.ShouldEmitDebugEntryValues()),
1051 PMW);
1053
1054 if (TM.Options.EnableMachineOutliner &&
1056 Opt.EnableMachineOutliner != RunOutliner::NeverOutline) {
1057 if (Opt.EnableMachineOutliner != RunOutliner::TargetDefault ||
1058 TM.Options.SupportsDefaultOutlining) {
1059 flushFPMsToMPM(PMW);
1060 addModulePass(MachineOutlinerPass(Opt.EnableMachineOutliner), PMW);
1061 }
1062 }
1063
1065
1066 // Add passes that directly emit MI after all other MI passes.
1067 derived().addPreEmitPass2(PMW);
1068
1069 return Error::success();
1070}
1071
1072/// Add passes that optimize machine instructions in SSA form.
1073template <typename Derived, typename TargetMachineT>
1075 PassManagerWrapper &PMW) const {
1076 // Pre-ra tail duplication.
1078
1079 // Optimize PHIs before DCE: removing dead PHI cycles may make more
1080 // instructions dead.
1082
1083 // This pass merges large allocas. StackSlotColoring is a different pass
1084 // which merges spill slots.
1086
1087 // If the target requests it, assign local variables to stack slots relative
1088 // to one another and simplify frame index references where possible.
1090
1091 // With optimization, dead code should already be eliminated. However
1092 // there is one known exception: lowered code for arguments that are only
1093 // used by tail calls, where the tail calls reuse the incoming stack
1094 // arguments directly (see t11 in test/CodeGen/X86/sibcall.ll).
1096
1097 // Allow targets to insert passes that improve instruction level parallelism,
1098 // like if-conversion. Such passes will typically need dominator trees and
1099 // loop info, just like LICM and CSE below.
1100 derived().addILPOpts(PMW);
1101
1104
1105 addMachineFunctionPass(MachineSinkingPass(Opt.EnableSinkAndFold), PMW);
1106
1108 // Clean-up the dead code that may have been generated by peephole
1109 // rewriting.
1111}
1112
1113//===---------------------------------------------------------------------===//
1114/// Register Allocation Pass Configuration
1115//===---------------------------------------------------------------------===//
1116
1117/// Instantiate the default register allocator pass for this target for either
1118/// the optimized or unoptimized allocation path. This will be added to the pass
1119/// manager by addFastRegAlloc in the unoptimized case or addOptimizedRegAlloc
1120/// in the optimized case.
1121///
1122/// A target that uses the standard regalloc pass order for fast or optimized
1123/// allocation may still override this for per-target regalloc
1124/// selection. But -regalloc-npm=... always takes precedence.
1125/// If a target does not want to allow users to set -regalloc-npm=... at all,
1126/// check if Opt.RegAlloc == RegAllocType::Unset.
1127template <typename Derived, typename TargetMachineT>
1129 PassManagerWrapper &PMW, bool Optimized) const {
1130 if (Optimized)
1132 else
1134}
1135
1136/// Find and instantiate the register allocation pass requested by this target
1137/// at the current optimization level. Different register allocators are
1138/// defined as separate passes because they may require different analysis.
1139///
1140/// This helper ensures that the -regalloc-npm= option is always available,
1141/// even for targets that override the default allocator.
1142template <typename Derived, typename TargetMachineT>
1144 PassManagerWrapper &PMW, bool Optimized) const {
1145 // Use the specified -regalloc-npm={basic|greedy|fast|pbqp}
1146 if (Opt.RegAlloc > RegAllocType::Default) {
1147 switch (Opt.RegAlloc) {
1148 case RegAllocType::Fast:
1150 break;
1153 break;
1154 default:
1155 reportFatalUsageError("register allocator not supported yet");
1156 }
1157 return;
1158 }
1159 // -regalloc=default or unspecified, so pick based on the optimization level
1160 // or ask the target for the regalloc pass.
1161 derived().addTargetRegisterAllocator(PMW, Optimized);
1162}
1163
1164template <typename Derived, typename TargetMachineT>
1166 PassManagerWrapper &PMW) const {
1167 // TODO: Ensure allocator is default or fast.
1168 addRegAllocPass(PMW, false);
1169 return Error::success();
1170}
1171
1172template <typename Derived, typename TargetMachineT>
1174 PassManagerWrapper &PMW) const {
1175 // Add the selected register allocation pass.
1176 addRegAllocPass(PMW, true);
1177
1178 // Allow targets to change the register assignments before rewriting.
1179 derived().addPreRewrite(PMW);
1180
1181 // Finally rewrite virtual registers.
1183 // Perform stack slot coloring and post-ra machine LICM.
1184 //
1185 // FIXME: Re-enable coloring with register when it's capable of adding
1186 // kill markers.
1188
1189 return Error::success();
1190}
1191
1192/// Add the minimum set of target-independent passes that are required for
1193/// register allocation. No coalescing or scheduling.
1194template <typename Derived, typename TargetMachineT>
1201
1202/// Add standard target-independent passes that are tightly coupled with
1203/// optimized register allocation, including coalescing, machine instruction
1204/// scheduling, and register allocation itself.
1205template <typename Derived, typename TargetMachineT>
1207 PassManagerWrapper &PMW) const {
1209
1211
1213
1214 // LiveVariables currently requires pure SSA form.
1215 //
1216 // FIXME: Once TwoAddressInstruction pass no longer uses kill flags,
1217 // LiveVariables can be removed completely, and LiveIntervals can be directly
1218 // computed. (We still either need to regenerate kill flags after regalloc, or
1219 // preferably fix the scavenger to not depend on them).
1220 // FIXME: UnreachableMachineBlockElim is a dependant pass of LiveVariables.
1221 // When LiveVariables is removed this has to be removed/moved either.
1222 // Explicit addition of UnreachableMachineBlockElim allows stopping before or
1223 // after it with -stop-before/-stop-after.
1227
1228 // Edge splitting is smarter with machine loop info.
1232
1233 // Eventually, we want to run LiveIntervals before PHI elimination.
1234 if (Opt.EarlyLiveIntervals)
1237
1240
1241 // The machine scheduler may accidentally create disconnected components
1242 // when moving subregister definitions around, avoid this by splitting them to
1243 // separate vregs before. Splitting can also improve reg. allocation quality.
1245
1246 // PreRA instruction scheduling.
1248
1249 if (auto E = derived().addRegAssignmentOptimized(PMW)) {
1250 // addRegAssignmentOptimized did not add a reg alloc pass, so do nothing.
1251 return;
1252 }
1253 // Allow targets to expand pseudo instructions depending on the choice of
1254 // registers before MachineCopyPropagation.
1255 derived().addPostRewrite(PMW);
1256
1257 // Copy propagate to forward register uses and try to eliminate COPYs that
1258 // were not coalesced.
1260
1261 // Run post-ra machine LICM to hoist reloads / remats.
1262 //
1263 // FIXME: can this move into MachineLateOptimization?
1265}
1266
1267//===---------------------------------------------------------------------===//
1268/// Post RegAlloc Pass Configuration
1269//===---------------------------------------------------------------------===//
1270
1271/// Add passes that optimize machine instructions after register allocation.
1272template <typename Derived, typename TargetMachineT>
1274 PassManagerWrapper &PMW) const {
1275 // Branch folding must be run after regalloc and prolog/epilog insertion.
1276 addMachineFunctionPass(BranchFolderPass(Opt.EnableTailMerge), PMW);
1277
1278 // Tail duplication.
1279 // Note that duplicating tail just increases code size and degrades
1280 // performance for targets that require Structured Control Flow.
1281 // In addition it can also make CFG irreducible. Thus we disable it.
1282 if (!TM.requiresStructuredCFG())
1284
1285 // Cleanup of redundant (identical) address/immediate loads.
1287
1288 // Copy propagation.
1290}
1291
1292/// Add standard basic block placement passes.
1293template <typename Derived, typename TargetMachineT>
1295 PassManagerWrapper &PMW) const {
1297 // Run a separate pass to collect block placement statistics.
1298 if (Opt.EnableBlockPlacementStats)
1300}
1301
1302} // namespace llvm
1303
1304#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.