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"
64#include "llvm/CodeGen/PEI.h"
101#include "llvm/IR/PassManager.h"
102#include "llvm/IR/Verifier.h"
104#include "llvm/MC/MCAsmInfo.h"
106#include "llvm/Support/CodeGen.h"
107#include "llvm/Support/Debug.h"
108#include "llvm/Support/Error.h"
124#include <cassert>
125#include <utility>
126
127namespace llvm {
128
129// FIXME: Dummy target independent passes definitions that have not yet been
130// ported to new pass manager. Once they do, remove these.
131#define DUMMY_FUNCTION_PASS(NAME, PASS_NAME) \
132 struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
133 template <typename... Ts> PASS_NAME(Ts &&...) {} \
134 PreservedAnalyses run(Function &, FunctionAnalysisManager &) { \
135 return PreservedAnalyses::all(); \
136 } \
137 };
138#define DUMMY_MACHINE_MODULE_PASS(NAME, PASS_NAME) \
139 struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
140 template <typename... Ts> PASS_NAME(Ts &&...) {} \
141 PreservedAnalyses run(Module &, ModuleAnalysisManager &) { \
142 return PreservedAnalyses::all(); \
143 } \
144 };
145#define DUMMY_MACHINE_FUNCTION_PASS(NAME, PASS_NAME) \
146 struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
147 template <typename... Ts> PASS_NAME(Ts &&...) {} \
148 PreservedAnalyses run(MachineFunction &, \
149 MachineFunctionAnalysisManager &) { \
150 return PreservedAnalyses::all(); \
151 } \
152 };
153#include "llvm/Passes/MachinePassRegistry.def"
154
155class PassManagerWrapper {
156private:
157 PassManagerWrapper(ModulePassManager &ModulePM) : MPM(ModulePM) {};
158
162
163 template <typename DerivedT, typename TargetMachineT>
164 friend class CodeGenPassBuilder;
165};
166
167/// This class provides access to building LLVM's passes.
168///
169/// Its members provide the baseline state available to passes during their
170/// construction. The \c MachinePassRegistry.def file specifies how to construct
171/// all of the built-in passes, and those may reference these members during
172/// construction.
173template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
174public:
175 explicit CodeGenPassBuilder(TargetMachineT &TM,
176 const CGPassBuilderOption &Opts,
178 : TM(TM), Opt(Opts), PIC(PIC) {
179 // Target could set CGPassBuilderOption::MISchedPostRA to true to achieve
180 // substitutePass(&PostRASchedulerID, &PostMachineSchedulerID)
181
182 // Target should override TM.Options.EnableIPRA in their target-specific
183 // LLVMTM ctor. See TargetMachine::setGlobalISel for example.
184 if (Opt.EnableIPRA) {
185 TM.Options.EnableIPRA = *Opt.EnableIPRA;
186 } else {
187 // If not explicitly specified, use target default.
188 TM.Options.EnableIPRA |= TM.useIPRA();
189 }
190
191 if (Opt.EnableGlobalISelAbort)
192 TM.Options.GlobalISelAbort = *Opt.EnableGlobalISelAbort;
193
194 if (!Opt.OptimizeRegAlloc)
195 Opt.OptimizeRegAlloc = getOptLevel() != CodeGenOptLevel::None;
196 }
197
199 raw_pwrite_stream *DwoOut,
200 CodeGenFileType FileType) const;
201
205
206protected:
207 template <typename PassT>
208 using is_module_pass_t = decltype(std::declval<PassT &>().run(
209 std::declval<Module &>(), std::declval<ModuleAnalysisManager &>()));
210
211 template <typename PassT>
212 using is_function_pass_t = decltype(std::declval<PassT &>().run(
213 std::declval<Function &>(), std::declval<FunctionAnalysisManager &>()));
214
215 template <typename PassT>
216 using is_machine_function_pass_t = decltype(std::declval<PassT &>().run(
217 std::declval<MachineFunction &>(),
218 std::declval<MachineFunctionAnalysisManager &>()));
219
220 template <typename PassT>
222 bool Force = false,
223 StringRef Name = PassT::name()) const {
225 "Only function passes are supported.");
226 if (!Force && !runBeforeAdding(Name))
227 return;
228 PMW.FPM.addPass(std::forward<PassT>(Pass));
229 }
230
231 template <typename PassT>
232 void addModulePass(PassT &&Pass, PassManagerWrapper &PMW, bool Force = false,
233 StringRef Name = PassT::name()) const {
235 "Only module passes are suported.");
236 assert(PMW.FPM.isEmpty() && PMW.MFPM.isEmpty() &&
237 "You cannot insert a module pass without first flushing the current "
238 "function pipelines to the module pipeline.");
239 if (!Force && !runBeforeAdding(Name))
240 return;
241 PMW.MPM.addPass(std::forward<PassT>(Pass));
242 }
243
244 template <typename PassT>
246 bool Force = false,
247 StringRef Name = PassT::name()) const {
249 "Only machine function passes are supported.");
250
251 if (!Force && !runBeforeAdding(Name))
252 return;
253 PMW.MFPM.addPass(std::forward<PassT>(Pass));
254 for (auto &C : AfterCallbacks)
255 C(Name, PMW.MFPM);
256 }
257
259 bool FreeMachineFunctions = false) const {
260 if (PMW.FPM.isEmpty() && PMW.MFPM.isEmpty())
261 return;
262 if (!PMW.MFPM.isEmpty()) {
263 PMW.FPM.addPass(
264 createFunctionToMachineFunctionPassAdaptor(std::move(PMW.MFPM)));
265 PMW.MFPM = MachineFunctionPassManager();
266 }
267 if (FreeMachineFunctions)
269 if (AddInCGSCCOrder) {
271 createCGSCCToFunctionPassAdaptor(std::move(PMW.FPM))));
272 } else {
273 PMW.MPM.addPass(createModuleToFunctionPassAdaptor(std::move(PMW.FPM)));
274 }
275 PMW.FPM = FunctionPassManager();
276 }
277
279 assert(!AddInCGSCCOrder);
280 assert(PMW.FPM.isEmpty() && PMW.MFPM.isEmpty() &&
281 "Requiring CGSCC ordering requires flushing the current function "
282 "pipelines to the MPM.");
283 AddInCGSCCOrder = true;
284 }
285
287 assert(AddInCGSCCOrder);
288 assert(PMW.FPM.isEmpty() && PMW.MFPM.isEmpty() &&
289 "Stopping CGSCC ordering requires flushing the current function "
290 "pipelines to the MPM.");
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
491 std::function<Expected<std::unique_ptr<MCStreamer>>(MCContext &)>;
493 llvm_unreachable("addAsmPrinter is not overridden");
494 }
495
496 /// Utilities for targets to add passes to the pass manager.
497 ///
498
499 /// createTargetRegisterAllocator - Create the register allocator pass for
500 /// this target at the current optimization level.
502 bool Optimized) const;
503
504 /// addMachinePasses helper to create the target-selected or overriden
505 /// regalloc pass.
506 void addRegAllocPass(PassManagerWrapper &PMW, bool Optimized) const;
507
508 /// Add core register alloator passes which do the actual register assignment
509 /// and rewriting. \returns true if any passes were added.
512
513 /// Allow the target to disable a specific pass by default.
514 /// Backend can declare unwanted passes in constructor.
515 template <typename... PassTs> void disablePass() {
516 BeforeCallbacks.emplace_back(
517 [](StringRef Name) { return ((Name != PassTs::name()) && ...); });
518 }
519
520 /// Insert InsertedPass pass after TargetPass pass.
521 /// Only machine function passes are supported.
522 template <typename TargetPassT, typename InsertedPassT>
523 void insertPass(InsertedPassT &&Pass) const {
524 AfterCallbacks.emplace_back(
525 [&](StringRef Name, MachineFunctionPassManager &MFPM) mutable {
526 if (Name == TargetPassT::name() &&
527 runBeforeAdding(InsertedPassT::name())) {
528 MFPM.addPass(std::forward<InsertedPassT>(Pass));
529 }
530 });
531 }
532
533private:
534 DerivedT &derived() { return static_cast<DerivedT &>(*this); }
535 const DerivedT &derived() const {
536 return static_cast<const DerivedT &>(*this);
537 }
538
539 bool runBeforeAdding(StringRef Name) const {
540 bool ShouldAdd = true;
541 for (auto &C : BeforeCallbacks)
542 ShouldAdd &= C(Name);
543 return ShouldAdd;
544 }
545
546 void setStartStopPasses(const TargetPassConfig::StartStopInfo &Info) const;
547
548 Error verifyStartStop(const TargetPassConfig::StartStopInfo &Info) const;
549
550 mutable SmallVector<llvm::unique_function<bool(StringRef)>, 4>
551 BeforeCallbacks;
552 mutable SmallVector<
553 llvm::unique_function<void(StringRef, MachineFunctionPassManager &)>, 4>
554 AfterCallbacks;
555
556 /// Helper variable for `-start-before/-start-after/-stop-before/-stop-after`
557 mutable bool Started = true;
558 mutable bool Stopped = true;
559 mutable bool AddInCGSCCOrder = false;
560};
561
562template <typename Derived, typename TargetMachineT>
565 CodeGenFileType FileType) const {
566 auto StartStopInfo = TargetPassConfig::getStartStopInfo(*PIC);
567 if (!StartStopInfo)
568 return StartStopInfo.takeError();
569 setStartStopPasses(*StartStopInfo);
570
572 bool PrintMIR = !PrintAsm && FileType != CodeGenFileType::Null;
573
574 PassManagerWrapper PMW(MPM);
575
577 /*Force=*/true);
579 /*Force=*/true);
581 /*Force=*/true);
583 /*Force=*/true);
584 addISelPasses(PMW);
585 flushFPMsToMPM(PMW);
586
587 if (PrintMIR)
588 addModulePass(PrintMIRPreparePass(Out), PMW, /*Force=*/true);
589
590 if (auto Err = addCoreISelPasses(PMW))
591 return std::move(Err);
592
593 if (auto Err = derived().addMachinePasses(PMW))
594 return std::move(Err);
595
596 if (!Opt.DisableVerify)
598
599 if (PrintAsm) {
600 derived().addAsmPrinter(
601 PMW, [this, &Out, DwoOut, FileType](MCContext &Ctx) {
602 return this->TM.createMCStreamer(Out, DwoOut, FileType, Ctx);
603 });
604 }
605
606 if (PrintMIR)
607 addMachineFunctionPass(PrintMIRPass(Out), PMW, /*Force=*/true);
608
609 flushFPMsToMPM(PMW, /*FreeMachineFunctions=*/true);
610
611 return verifyStartStop(*StartStopInfo);
612}
613
614template <typename Derived, typename TargetMachineT>
615void CodeGenPassBuilder<Derived, TargetMachineT>::setStartStopPasses(
616 const TargetPassConfig::StartStopInfo &Info) const {
617 if (!Info.StartPass.empty()) {
618 Started = false;
619 BeforeCallbacks.emplace_back([this, &Info, AfterFlag = Info.StartAfter,
620 Count = 0u](StringRef ClassName) mutable {
621 if (Count == Info.StartInstanceNum) {
622 if (AfterFlag) {
623 AfterFlag = false;
624 Started = true;
625 }
626 return Started;
627 }
628
629 auto PassName = PIC->getPassNameForClassName(ClassName);
630 if (Info.StartPass == PassName && ++Count == Info.StartInstanceNum)
631 Started = !Info.StartAfter;
632
633 return Started;
634 });
635 }
636
637 if (!Info.StopPass.empty()) {
638 Stopped = false;
639 BeforeCallbacks.emplace_back([this, &Info, AfterFlag = Info.StopAfter,
640 Count = 0u](StringRef ClassName) mutable {
641 if (Count == Info.StopInstanceNum) {
642 if (AfterFlag) {
643 AfterFlag = false;
644 Stopped = true;
645 }
646 return !Stopped;
647 }
648
649 auto PassName = PIC->getPassNameForClassName(ClassName);
650 if (Info.StopPass == PassName && ++Count == Info.StopInstanceNum)
651 Stopped = !Info.StopAfter;
652 return !Stopped;
653 });
654 }
655}
656
657template <typename Derived, typename TargetMachineT>
658Error CodeGenPassBuilder<Derived, TargetMachineT>::verifyStartStop(
660 if (Started && Stopped)
661 return Error::success();
662
663 if (!Started)
665 "Can't find start pass \"" + Info.StartPass + "\".",
666 std::make_error_code(std::errc::invalid_argument));
667 if (!Stopped)
669 "Can't find stop pass \"" + Info.StopPass + "\".",
670 std::make_error_code(std::errc::invalid_argument));
671 return Error::success();
672}
673
674template <typename Derived, typename TargetMachineT>
676 PassManagerWrapper &PMW) const {
677 derived().addGlobalMergePass(PMW);
678 if (TM.useEmulatedTLS())
680
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 }
731
732 // Make sure that no unreachable blocks are instruction selected.
734
735 // Prepare expensive constants for SelectionDAG.
736 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableConstantHoisting)
738
739 // Replace calls to LLVM intrinsics (e.g., exp, log) operating on vector
740 // operands with calls to the corresponding functions in a vector library.
743
745 !Opt.DisablePartialLibcallInlining)
747
748 // Instrument function entry and exit, e.g. with calls to mcount().
749 addFunctionPass(EntryExitInstrumenterPass(/*PostInlining=*/true), PMW);
750
751 // Add scalarization of target's unsupported masked memory intrinsics pass.
752 // the unsupported intrinsic will be replaced with a chain of basic blocks,
753 // that stores/loads element one-by-one if the appropriate mask bit is set.
755
756 // Expand reduction intrinsics into shuffle sequences if the target wants to.
757 if (!Opt.DisableExpandReductions)
759
760 // Convert conditional moves to conditional jumps when profitable.
761 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableSelectOptimize)
763
764 if (Opt.EnableGlobalMergeFunc) {
765 flushFPMsToMPM(PMW);
767 }
768}
769
770/// Turn exception handling constructs into something the code generators can
771/// handle.
772template <typename Derived, typename TargetMachineT>
774 PassManagerWrapper &PMW) const {
775 const MCAsmInfo *MCAI = TM.getMCAsmInfo();
776 assert(MCAI && "No MCAsmInfo");
777 switch (MCAI->getExceptionHandlingType()) {
779 // SjLj piggy-backs on dwarf for this bit. The cleanups done apply to both
780 // Dwarf EH prepare needs to be run after SjLj prepare. Otherwise,
781 // catch info can get misplaced when a selector ends up more than one block
782 // removed from the parent invoke(s). This could happen when a landing
783 // pad is shared by multiple invokes and is also a target of a normal
784 // edge from elsewhere.
786 [[fallthrough]];
792 break;
794 // We support using both GCC-style and MSVC-style exceptions on Windows, so
795 // add both preparation passes. Each pass will only actually run if it
796 // recognizes the personality function.
799 break;
801 // Wasm EH uses Windows EH instructions, but it does not need to demote PHIs
802 // on catchpads and cleanuppads because it does not outline them into
803 // funclets. Catchswitch blocks are not lowered in SelectionDAG, so we
804 // should remove PHIs there.
805 addFunctionPass(WinEHPreparePass(/*DemoteCatchSwitchPHIOnly=*/false), PMW);
807 break;
810
811 // The lower invoke pass may create unreachable code. Remove it.
813 break;
814 }
815}
816
817/// Add pass to prepare the LLVM IR for code generation. This should be done
818/// before exception handling preparation passes.
819template <typename Derived, typename TargetMachineT>
821 PassManagerWrapper &PMW) const {
822 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableCGP)
824 // TODO: Default ctor'd RewriteSymbolPass is no-op.
825 // addPass(RewriteSymbolPass());
826}
827
828/// Add common passes that perform LLVM IR to IR transforms in preparation for
829/// instruction selection.
830template <typename Derived, typename TargetMachineT>
832 PassManagerWrapper &PMW) const {
833 derived().addPreISel(PMW);
834
835 if (Opt.RequiresCodeGenSCCOrder && !AddInCGSCCOrder)
837
840
842 // Add both the safe stack and the stack protection passes: each of them will
843 // only protect functions that have corresponding attributes.
846
847 if (Opt.PrintISelInput)
849 dbgs(), "\n\n*** Final LLVM Code input to ISel ***\n"),
850 PMW);
851
852 // All passes which modify the LLVM IR are now complete; run the verifier
853 // to ensure that the IR is valid.
854 if (!Opt.DisableVerify)
855 addFunctionPass(VerifierPass(), PMW, /*Force=*/true);
856}
857
858template <typename Derived, typename TargetMachineT>
860 PassManagerWrapper &PMW) const {
861 // Enable FastISel with -fast-isel, but allow that to be overridden.
862 TM.setO0WantsFastISel(Opt.EnableFastISelOption.value_or(true));
863
864 // Determine an instruction selector.
865 enum class SelectorType { SelectionDAG, FastISel, GlobalISel };
866 SelectorType Selector;
867
868 if (Opt.EnableFastISelOption && *Opt.EnableFastISelOption == true)
869 Selector = SelectorType::FastISel;
870 else if ((Opt.EnableGlobalISelOption &&
871 *Opt.EnableGlobalISelOption == true) ||
872 (TM.Options.EnableGlobalISel &&
873 (!Opt.EnableGlobalISelOption ||
874 *Opt.EnableGlobalISelOption == false)))
875 Selector = SelectorType::GlobalISel;
876 else if (TM.getOptLevel() == CodeGenOptLevel::None && TM.getO0WantsFastISel())
877 Selector = SelectorType::FastISel;
878 else
879 Selector = SelectorType::SelectionDAG;
880
881 // Set consistently TM.Options.EnableFastISel and EnableGlobalISel.
882 if (Selector == SelectorType::FastISel) {
883 TM.setFastISel(true);
884 TM.setGlobalISel(false);
885 } else if (Selector == SelectorType::GlobalISel) {
886 TM.setFastISel(false);
887 TM.setGlobalISel(true);
888 }
889
890 // Add instruction selector passes.
891 if (Selector == SelectorType::GlobalISel) {
892 if (auto Err = derived().addIRTranslator(PMW))
893 return std::move(Err);
894
895 derived().addPreLegalizeMachineIR(PMW);
896
897 if (auto Err = derived().addLegalizeMachineIR(PMW))
898 return std::move(Err);
899
900 // Before running the register bank selector, ask the target if it
901 // wants to run some passes.
902 derived().addPreRegBankSelect(PMW);
903
904 if (auto Err = derived().addRegBankSelect(PMW))
905 return std::move(Err);
906
907 derived().addPreGlobalInstructionSelect(PMW);
908
909 if (auto Err = derived().addGlobalInstructionSelect(PMW))
910 return std::move(Err);
911
912 // Pass to reset the MachineFunction if the ISel failed.
914 ResetMachineFunctionPass(reportDiagnosticWhenGlobalISelFallback(),
916 PMW);
917
918 // Provide a fallback path when we do not want to abort on
919 // not-yet-supported input.
921 if (auto Err = derived().addInstSelector(PMW))
922 return std::move(Err);
923
924 } else if (auto Err = derived().addInstSelector(PMW))
925 return std::move(Err);
926
927 // Expand pseudo-instructions emitted by ISel. Don't run the verifier before
928 // FinalizeISel.
930
931 // // Print the instruction selected machine code...
932 // printAndVerify("After Instruction Selection");
933
934 return Error::success();
935}
936
937/// Add the complete set of target-independent postISel code generator passes.
938///
939/// This can be read as the standard order of major LLVM CodeGen stages. Stages
940/// with nontrivial configuration or multiple passes are broken out below in
941/// add%Stage routines.
942///
943/// Any CodeGenPassBuilder<Derived, TargetMachine>::addXX routine may be
944/// overriden by the Target. The addPre/Post methods with empty header
945/// implementations allow injecting target-specific fixups just before or after
946/// major stages. Additionally, targets have the flexibility to change pass
947/// order within a stage by overriding default implementation of add%Stage
948/// routines below. Each technique has maintainability tradeoffs because
949/// alternate pass orders are not well supported. addPre/Post works better if
950/// the target pass is easily tied to a common pass. But if it has subtle
951/// dependencies on multiple passes, the target should override the stage
952/// instead.
953template <typename Derived, typename TargetMachineT>
955 PassManagerWrapper &PMW) const {
956 // Add passes that optimize machine instructions in SSA form.
958 derived().addMachineSSAOptimization(PMW);
959 } else {
960 // If the target requests it, assign local variables to stack slots relative
961 // to one another and simplify frame index references where possible.
963 }
964
965 if (TM.Options.EnableIPRA) {
966 flushFPMsToMPM(PMW);
968 PMW);
970 }
971 // Run pre-ra passes.
972 derived().addPreRegAlloc(PMW);
973
974 // Run register allocation and passes that are tightly coupled with it,
975 // including phi elimination and scheduling.
976 if (*Opt.OptimizeRegAlloc) {
977 derived().addOptimizedRegAlloc(PMW);
978 } else {
979 if (auto Err = derived().addFastRegAlloc(PMW))
980 return Err;
981 }
982
983 // Run post-ra passes.
984 derived().addPostRegAlloc(PMW);
985
988
989 // Insert prolog/epilog code. Eliminate abstract frame index references...
993 }
994
996
997 /// Add passes that optimize machine instructions after register allocation.
999 derived().addMachineLateOptimization(PMW);
1000
1001 // Expand pseudo instructions before second scheduling pass.
1003
1004 // Run pre-sched2 passes.
1005 derived().addPreSched2(PMW);
1006
1007 if (Opt.EnableImplicitNullChecks)
1008 addMachineFunctionPass(ImplicitNullChecksPass(), PMW);
1009
1010 // Second pass scheduler.
1011 // Let Target optionally insert this pass by itself at some other
1012 // point.
1014 !TM.targetSchedulesPostRAScheduling()) {
1015 if (Opt.MISchedPostRA)
1017 else
1019 }
1020
1021 // GC
1022 derived().addGCPasses(PMW);
1023
1024 // Basic block placement.
1026 derived().addBlockPlacement(PMW);
1027
1028 // Insert before XRay Instrumentation.
1030
1033
1034 derived().addPreEmitPass(PMW);
1035
1036 if (TM.Options.EnableIPRA) {
1037 // Collect register usage information and produce a register mask of
1038 // clobbered registers, to be used to optimize call sites.
1039 flushFPMsToMPM(PMW);
1041 PMW);
1043 }
1044
1045 addMachineFunctionPass(FuncletLayoutPass(), PMW);
1046
1048 addMachineFunctionPass(StackMapLivenessPass(), PMW);
1051 getTM<TargetMachine>().Options.ShouldEmitDebugEntryValues()),
1052 PMW);
1054
1055 if (TM.Options.EnableMachineOutliner &&
1057 Opt.EnableMachineOutliner != RunOutliner::NeverOutline) {
1058 if (Opt.EnableMachineOutliner != RunOutliner::TargetDefault ||
1059 TM.Options.SupportsDefaultOutlining) {
1060 flushFPMsToMPM(PMW);
1061 addModulePass(MachineOutlinerPass(Opt.EnableMachineOutliner), PMW);
1062 }
1063 }
1064
1065 derived().addPostBBSections(PMW);
1066
1068
1069 // Add passes that directly emit MI after all other MI passes.
1070 derived().addPreEmitPass2(PMW);
1071
1072 return Error::success();
1073}
1074
1075/// Add passes that optimize machine instructions in SSA form.
1076template <typename Derived, typename TargetMachineT>
1078 PassManagerWrapper &PMW) const {
1079 // Pre-ra tail duplication.
1081
1082 // Optimize PHIs before DCE: removing dead PHI cycles may make more
1083 // instructions dead.
1085
1086 // This pass merges large allocas. StackSlotColoring is a different pass
1087 // which merges spill slots.
1089
1090 // If the target requests it, assign local variables to stack slots relative
1091 // to one another and simplify frame index references where possible.
1093
1094 // With optimization, dead code should already be eliminated. However
1095 // there is one known exception: lowered code for arguments that are only
1096 // used by tail calls, where the tail calls reuse the incoming stack
1097 // arguments directly (see t11 in test/CodeGen/X86/sibcall.ll).
1099
1100 // Allow targets to insert passes that improve instruction level parallelism,
1101 // like if-conversion. Such passes will typically need dominator trees and
1102 // loop info, just like LICM and CSE below.
1103 derived().addILPOpts(PMW);
1104
1107
1108 addMachineFunctionPass(MachineSinkingPass(Opt.EnableSinkAndFold), PMW);
1109
1111 // Clean-up the dead code that may have been generated by peephole
1112 // rewriting.
1114}
1115
1116//===---------------------------------------------------------------------===//
1117/// Register Allocation Pass Configuration
1118//===---------------------------------------------------------------------===//
1119
1120/// Instantiate the default register allocator pass for this target for either
1121/// the optimized or unoptimized allocation path. This will be added to the pass
1122/// manager by addFastRegAlloc in the unoptimized case or addOptimizedRegAlloc
1123/// in the optimized case.
1124///
1125/// A target that uses the standard regalloc pass order for fast or optimized
1126/// allocation may still override this for per-target regalloc
1127/// selection. But -regalloc-npm=... always takes precedence.
1128/// If a target does not want to allow users to set -regalloc-npm=... at all,
1129/// check if Opt.RegAlloc == RegAllocType::Unset.
1130template <typename Derived, typename TargetMachineT>
1132 PassManagerWrapper &PMW, bool Optimized) const {
1133 if (Optimized)
1135 else
1137}
1138
1139/// Find and instantiate the register allocation pass requested by this target
1140/// at the current optimization level. Different register allocators are
1141/// defined as separate passes because they may require different analysis.
1142///
1143/// This helper ensures that the -regalloc-npm= option is always available,
1144/// even for targets that override the default allocator.
1145template <typename Derived, typename TargetMachineT>
1147 PassManagerWrapper &PMW, bool Optimized) const {
1148 // Use the specified -regalloc-npm={basic|greedy|fast|pbqp}
1149 if (Opt.RegAlloc > RegAllocType::Default) {
1150 switch (Opt.RegAlloc) {
1151 case RegAllocType::Fast:
1153 break;
1156 break;
1157 default:
1158 reportFatalUsageError("register allocator not supported yet");
1159 }
1160 return;
1161 }
1162 // -regalloc=default or unspecified, so pick based on the optimization level
1163 // or ask the target for the regalloc pass.
1164 derived().addTargetRegisterAllocator(PMW, Optimized);
1165}
1166
1167template <typename Derived, typename TargetMachineT>
1169 PassManagerWrapper &PMW) const {
1170 // TODO: Ensure allocator is default or fast.
1171 addRegAllocPass(PMW, false);
1172 return Error::success();
1173}
1174
1175template <typename Derived, typename TargetMachineT>
1177 PassManagerWrapper &PMW) const {
1178 // Add the selected register allocation pass.
1179 addRegAllocPass(PMW, true);
1180
1181 // Allow targets to change the register assignments before rewriting.
1182 derived().addPreRewrite(PMW);
1183
1184 // Finally rewrite virtual registers.
1186 // Perform stack slot coloring and post-ra machine LICM.
1187 //
1188 // FIXME: Re-enable coloring with register when it's capable of adding
1189 // kill markers.
1191
1192 return Error::success();
1193}
1194
1195/// Add the minimum set of target-independent passes that are required for
1196/// register allocation. No coalescing or scheduling.
1197template <typename Derived, typename TargetMachineT>
1204
1205/// Add standard target-independent passes that are tightly coupled with
1206/// optimized register allocation, including coalescing, machine instruction
1207/// scheduling, and register allocation itself.
1208template <typename Derived, typename TargetMachineT>
1210 PassManagerWrapper &PMW) const {
1212
1214
1216
1217 // LiveVariables currently requires pure SSA form.
1218 //
1219 // FIXME: Once TwoAddressInstruction pass no longer uses kill flags,
1220 // LiveVariables can be removed completely, and LiveIntervals can be directly
1221 // computed. (We still either need to regenerate kill flags after regalloc, or
1222 // preferably fix the scavenger to not depend on them).
1223 // FIXME: UnreachableMachineBlockElim is a dependant pass of LiveVariables.
1224 // When LiveVariables is removed this has to be removed/moved either.
1225 // Explicit addition of UnreachableMachineBlockElim allows stopping before or
1226 // after it with -stop-before/-stop-after.
1230
1231 // Edge splitting is smarter with machine loop info.
1235
1236 // Eventually, we want to run LiveIntervals before PHI elimination.
1237 if (Opt.EarlyLiveIntervals)
1240
1243
1244 // The machine scheduler may accidentally create disconnected components
1245 // when moving subregister definitions around, avoid this by splitting them to
1246 // separate vregs before. Splitting can also improve reg. allocation quality.
1248
1249 // PreRA instruction scheduling.
1251
1252 if (auto E = derived().addRegAssignmentOptimized(PMW)) {
1253 // addRegAssignmentOptimized did not add a reg alloc pass, so do nothing.
1254 return;
1255 }
1256
1258
1259 // Allow targets to expand pseudo instructions depending on the choice of
1260 // registers before MachineCopyPropagation.
1261 derived().addPostRewrite(PMW);
1262
1263 // Copy propagate to forward register uses and try to eliminate COPYs that
1264 // were not coalesced.
1266
1267 // Run post-ra machine LICM to hoist reloads / remats.
1268 //
1269 // FIXME: can this move into MachineLateOptimization?
1271}
1272
1273//===---------------------------------------------------------------------===//
1274/// Post RegAlloc Pass Configuration
1275//===---------------------------------------------------------------------===//
1276
1277/// Add passes that optimize machine instructions after register allocation.
1278template <typename Derived, typename TargetMachineT>
1280 PassManagerWrapper &PMW) const {
1281 // Cleanup of redundant (identical) address/immediate loads.
1283
1284 // Branch folding must be run after regalloc and prolog/epilog insertion.
1285 addMachineFunctionPass(BranchFolderPass(Opt.EnableTailMerge), PMW);
1286
1287 // Tail duplication.
1288 // Note that duplicating tail just increases code size and degrades
1289 // performance for targets that require Structured Control Flow.
1290 // In addition it can also make CFG irreducible. Thus we disable it.
1291 if (!TM.requiresStructuredCFG())
1293
1294 // Copy propagation.
1296}
1297
1298/// Add standard basic block placement passes.
1299template <typename Derived, typename TargetMachineT>
1301 PassManagerWrapper &PMW) const {
1303 // Run a separate pass to collect block placement statistics.
1304 if (Opt.EnableBlockPlacementStats)
1306}
1307
1308} // namespace llvm
1309
1310#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 addPostBBSections(PassManagerWrapper &PMW) const
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.
Definition Types.h:26
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.