LLVM 23.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);
585 PMW,
586 /*Force=*/true);
587 addISelPasses(PMW);
588 flushFPMsToMPM(PMW);
589
590 if (PrintMIR)
591 addModulePass(PrintMIRPreparePass(Out), PMW, /*Force=*/true);
592
593 if (auto Err = addCoreISelPasses(PMW))
594 return std::move(Err);
595
596 if (auto Err = derived().addMachinePasses(PMW))
597 return std::move(Err);
598
599 if (!Opt.DisableVerify)
601
602 if (PrintAsm) {
603 derived().addAsmPrinter(
604 PMW, [this, &Out, DwoOut, FileType](MCContext &Ctx) {
605 return this->TM.createMCStreamer(Out, DwoOut, FileType, Ctx);
606 });
607 }
608
609 if (PrintMIR)
610 addMachineFunctionPass(PrintMIRPass(Out), PMW, /*Force=*/true);
611
612 flushFPMsToMPM(PMW, /*FreeMachineFunctions=*/true);
613
614 return verifyStartStop(*StartStopInfo);
615}
616
617template <typename Derived, typename TargetMachineT>
618void CodeGenPassBuilder<Derived, TargetMachineT>::setStartStopPasses(
619 const TargetPassConfig::StartStopInfo &Info) const {
620 if (!Info.StartPass.empty()) {
621 Started = false;
622 BeforeCallbacks.emplace_back([this, &Info, AfterFlag = Info.StartAfter,
623 Count = 0u](StringRef ClassName) mutable {
624 if (Count == Info.StartInstanceNum) {
625 if (AfterFlag) {
626 AfterFlag = false;
627 Started = true;
628 }
629 return Started;
630 }
631
632 auto PassName = PIC->getPassNameForClassName(ClassName);
633 if (Info.StartPass == PassName && ++Count == Info.StartInstanceNum)
634 Started = !Info.StartAfter;
635
636 return Started;
637 });
638 }
639
640 if (!Info.StopPass.empty()) {
641 Stopped = false;
642 BeforeCallbacks.emplace_back([this, &Info, AfterFlag = Info.StopAfter,
643 Count = 0u](StringRef ClassName) mutable {
644 if (Count == Info.StopInstanceNum) {
645 if (AfterFlag) {
646 AfterFlag = false;
647 Stopped = true;
648 }
649 return !Stopped;
650 }
651
652 auto PassName = PIC->getPassNameForClassName(ClassName);
653 if (Info.StopPass == PassName && ++Count == Info.StopInstanceNum)
654 Stopped = !Info.StopAfter;
655 return !Stopped;
656 });
657 }
658}
659
660template <typename Derived, typename TargetMachineT>
661Error CodeGenPassBuilder<Derived, TargetMachineT>::verifyStartStop(
663 if (Started && Stopped)
664 return Error::success();
665
666 if (!Started)
668 "Can't find start pass \"" + Info.StartPass + "\".",
669 std::make_error_code(std::errc::invalid_argument));
670 if (!Stopped)
672 "Can't find stop pass \"" + Info.StopPass + "\".",
673 std::make_error_code(std::errc::invalid_argument));
674 return Error::success();
675}
676
677template <typename Derived, typename TargetMachineT>
679 PassManagerWrapper &PMW) const {
680 derived().addGlobalMergePass(PMW);
681 if (TM.useEmulatedTLS())
683
686
687 derived().addIRPasses(PMW);
688 derived().addCodeGenPrepare(PMW);
690 derived().addISelPrepare(PMW);
691}
692
693/// Add common target configurable passes that perform LLVM IR to IR transforms
694/// following machine independent optimization.
695template <typename Derived, typename TargetMachineT>
697 PassManagerWrapper &PMW) const {
698 // Before running any passes, run the verifier to determine if the input
699 // coming from the front-end and/or optimizer is valid.
700 if (!Opt.DisableVerify)
701 addFunctionPass(VerifierPass(), PMW, /*Force=*/true);
702
703 // Run loop strength reduction before anything else.
704 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableLSR) {
705 LoopPassManager LPM;
706 LPM.addPass(CanonicalizeFreezeInLoopsPass());
707 LPM.addPass(LoopStrengthReducePass());
708 if (Opt.EnableLoopTermFold)
709 LPM.addPass(LoopTermFoldPass());
711 /*UseMemorySSA=*/true),
712 PMW);
713 }
714
716 // The MergeICmpsPass tries to create memcmp calls by grouping sequences of
717 // loads and compares. ExpandMemCmpPass then tries to expand those calls
718 // into optimally-sized loads and compares. The transforms are enabled by a
719 // target lowering hook.
720 if (!Opt.DisableMergeICmps)
723 }
724
725 // Run GC lowering passes for builtin collectors
726 // TODO: add a pass insertion point here
728 // Explicitly check to see if we should add ShadowStackGCLowering to avoid
729 // splitting the function pipeline if we do not have to.
730 if (runBeforeAdding(ShadowStackGCLoweringPass::name())) {
731 flushFPMsToMPM(PMW);
733 }
734
735 // Make sure that no unreachable blocks are instruction selected.
737
738 // Prepare expensive constants for SelectionDAG.
739 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableConstantHoisting)
741
742 // Replace calls to LLVM intrinsics (e.g., exp, log) operating on vector
743 // operands with calls to the corresponding functions in a vector library.
746
748 !Opt.DisablePartialLibcallInlining)
750
751 // Instrument function entry and exit, e.g. with calls to mcount().
752 addFunctionPass(EntryExitInstrumenterPass(/*PostInlining=*/true), PMW);
753
754 // Add scalarization of target's unsupported masked memory intrinsics pass.
755 // the unsupported intrinsic will be replaced with a chain of basic blocks,
756 // that stores/loads element one-by-one if the appropriate mask bit is set.
758
759 // Expand reduction intrinsics into shuffle sequences if the target wants to.
760 if (!Opt.DisableExpandReductions)
762
763 // Convert conditional moves to conditional jumps when profitable.
764 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableSelectOptimize)
766
767 if (Opt.EnableGlobalMergeFunc) {
768 flushFPMsToMPM(PMW);
770 }
771}
772
773/// Turn exception handling constructs into something the code generators can
774/// handle.
775template <typename Derived, typename TargetMachineT>
777 PassManagerWrapper &PMW) const {
778 const MCAsmInfo *MCAI = TM.getMCAsmInfo();
779 assert(MCAI && "No MCAsmInfo");
780 switch (MCAI->getExceptionHandlingType()) {
782 // SjLj piggy-backs on dwarf for this bit. The cleanups done apply to both
783 // Dwarf EH prepare needs to be run after SjLj prepare. Otherwise,
784 // catch info can get misplaced when a selector ends up more than one block
785 // removed from the parent invoke(s). This could happen when a landing
786 // pad is shared by multiple invokes and is also a target of a normal
787 // edge from elsewhere.
789 [[fallthrough]];
795 break;
797 // We support using both GCC-style and MSVC-style exceptions on Windows, so
798 // add both preparation passes. Each pass will only actually run if it
799 // recognizes the personality function.
802 break;
804 // Wasm EH uses Windows EH instructions, but it does not need to demote PHIs
805 // on catchpads and cleanuppads because it does not outline them into
806 // funclets. Catchswitch blocks are not lowered in SelectionDAG, so we
807 // should remove PHIs there.
808 addFunctionPass(WinEHPreparePass(/*DemoteCatchSwitchPHIOnly=*/false), PMW);
810 break;
813
814 // The lower invoke pass may create unreachable code. Remove it.
816 break;
817 }
818}
819
820/// Add pass to prepare the LLVM IR for code generation. This should be done
821/// before exception handling preparation passes.
822template <typename Derived, typename TargetMachineT>
824 PassManagerWrapper &PMW) const {
825 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableCGP)
827 // TODO: Default ctor'd RewriteSymbolPass is no-op.
828 // addPass(RewriteSymbolPass());
829}
830
831/// Add common passes that perform LLVM IR to IR transforms in preparation for
832/// instruction selection.
833template <typename Derived, typename TargetMachineT>
835 PassManagerWrapper &PMW) const {
836 derived().addPreISel(PMW);
837
838 if (Opt.RequiresCodeGenSCCOrder && !AddInCGSCCOrder)
840
843
845 // Add both the safe stack and the stack protection passes: each of them will
846 // only protect functions that have corresponding attributes.
849
850 if (Opt.PrintISelInput)
852 dbgs(), "\n\n*** Final LLVM Code input to ISel ***\n"),
853 PMW);
854
855 // All passes which modify the LLVM IR are now complete; run the verifier
856 // to ensure that the IR is valid.
857 if (!Opt.DisableVerify)
858 addFunctionPass(VerifierPass(), PMW, /*Force=*/true);
859}
860
861template <typename Derived, typename TargetMachineT>
863 PassManagerWrapper &PMW) const {
864 // Enable FastISel with -fast-isel, but allow that to be overridden.
865 TM.setO0WantsFastISel(Opt.EnableFastISelOption.value_or(true));
866
867 // Determine an instruction selector.
868 enum class SelectorType { SelectionDAG, FastISel, GlobalISel };
869 SelectorType Selector;
870
871 if (Opt.EnableFastISelOption && *Opt.EnableFastISelOption == true)
872 Selector = SelectorType::FastISel;
873 else if ((Opt.EnableGlobalISelOption &&
874 *Opt.EnableGlobalISelOption == true) ||
875 (TM.Options.EnableGlobalISel &&
876 (!Opt.EnableGlobalISelOption ||
877 *Opt.EnableGlobalISelOption == false)))
878 Selector = SelectorType::GlobalISel;
879 else if (TM.getOptLevel() == CodeGenOptLevel::None && TM.getO0WantsFastISel())
880 Selector = SelectorType::FastISel;
881 else
882 Selector = SelectorType::SelectionDAG;
883
884 // Set consistently TM.Options.EnableFastISel and EnableGlobalISel.
885 if (Selector == SelectorType::FastISel) {
886 TM.setFastISel(true);
887 TM.setGlobalISel(false);
888 } else if (Selector == SelectorType::GlobalISel) {
889 TM.setFastISel(false);
890 TM.setGlobalISel(true);
891 }
892
893 // Add instruction selector passes.
894 if (Selector == SelectorType::GlobalISel) {
895 if (auto Err = derived().addIRTranslator(PMW))
896 return std::move(Err);
897
898 derived().addPreLegalizeMachineIR(PMW);
899
900 if (auto Err = derived().addLegalizeMachineIR(PMW))
901 return std::move(Err);
902
903 // Before running the register bank selector, ask the target if it
904 // wants to run some passes.
905 derived().addPreRegBankSelect(PMW);
906
907 if (auto Err = derived().addRegBankSelect(PMW))
908 return std::move(Err);
909
910 derived().addPreGlobalInstructionSelect(PMW);
911
912 if (auto Err = derived().addGlobalInstructionSelect(PMW))
913 return std::move(Err);
914
915 // Pass to reset the MachineFunction if the ISel failed.
917 ResetMachineFunctionPass(reportDiagnosticWhenGlobalISelFallback(),
919 PMW);
920
921 // Provide a fallback path when we do not want to abort on
922 // not-yet-supported input.
924 if (auto Err = derived().addInstSelector(PMW))
925 return std::move(Err);
926
927 } else if (auto Err = derived().addInstSelector(PMW))
928 return std::move(Err);
929
930 // Expand pseudo-instructions emitted by ISel. Don't run the verifier before
931 // FinalizeISel.
933
934 // // Print the instruction selected machine code...
935 // printAndVerify("After Instruction Selection");
936
937 return Error::success();
938}
939
940/// Add the complete set of target-independent postISel code generator passes.
941///
942/// This can be read as the standard order of major LLVM CodeGen stages. Stages
943/// with nontrivial configuration or multiple passes are broken out below in
944/// add%Stage routines.
945///
946/// Any CodeGenPassBuilder<Derived, TargetMachine>::addXX routine may be
947/// overriden by the Target. The addPre/Post methods with empty header
948/// implementations allow injecting target-specific fixups just before or after
949/// major stages. Additionally, targets have the flexibility to change pass
950/// order within a stage by overriding default implementation of add%Stage
951/// routines below. Each technique has maintainability tradeoffs because
952/// alternate pass orders are not well supported. addPre/Post works better if
953/// the target pass is easily tied to a common pass. But if it has subtle
954/// dependencies on multiple passes, the target should override the stage
955/// instead.
956template <typename Derived, typename TargetMachineT>
958 PassManagerWrapper &PMW) const {
959 // Add passes that optimize machine instructions in SSA form.
961 derived().addMachineSSAOptimization(PMW);
962 } else {
963 // If the target requests it, assign local variables to stack slots relative
964 // to one another and simplify frame index references where possible.
966 }
967
968 if (TM.Options.EnableIPRA) {
969 flushFPMsToMPM(PMW);
971 PMW);
973 }
974 // Run pre-ra passes.
975 derived().addPreRegAlloc(PMW);
976
977 // Run register allocation and passes that are tightly coupled with it,
978 // including phi elimination and scheduling.
979 if (*Opt.OptimizeRegAlloc) {
980 derived().addOptimizedRegAlloc(PMW);
981 } else {
982 if (auto Err = derived().addFastRegAlloc(PMW))
983 return Err;
984 }
985
986 // Run post-ra passes.
987 derived().addPostRegAlloc(PMW);
988
991
992 // Insert prolog/epilog code. Eliminate abstract frame index references...
996 }
997
999
1000 /// Add passes that optimize machine instructions after register allocation.
1002 derived().addMachineLateOptimization(PMW);
1003
1004 // Expand pseudo instructions before second scheduling pass.
1006
1007 // Run pre-sched2 passes.
1008 derived().addPreSched2(PMW);
1009
1010 if (Opt.EnableImplicitNullChecks)
1011 addMachineFunctionPass(ImplicitNullChecksPass(), PMW);
1012
1013 // Second pass scheduler.
1014 // Let Target optionally insert this pass by itself at some other
1015 // point.
1017 !TM.targetSchedulesPostRAScheduling()) {
1018 if (Opt.MISchedPostRA)
1020 else
1022 }
1023
1024 // GC
1025 derived().addGCPasses(PMW);
1026
1027 // Basic block placement.
1029 derived().addBlockPlacement(PMW);
1030
1031 // Insert before XRay Instrumentation.
1033
1036
1037 derived().addPreEmitPass(PMW);
1038
1039 if (TM.Options.EnableIPRA) {
1040 // Collect register usage information and produce a register mask of
1041 // clobbered registers, to be used to optimize call sites.
1042 flushFPMsToMPM(PMW);
1044 PMW);
1046 // If -print-regusage is specified, print the collected register usage info.
1047 if (Opt.PrintRegUsage) {
1048 flushFPMsToMPM(PMW);
1050 }
1051 }
1052
1053 addMachineFunctionPass(FuncletLayoutPass(), PMW);
1054
1056 addMachineFunctionPass(StackMapLivenessPass(), PMW);
1059 getTM<TargetMachine>().Options.ShouldEmitDebugEntryValues()),
1060 PMW);
1062
1063 if (TM.Options.EnableMachineOutliner &&
1065 Opt.EnableMachineOutliner != RunOutliner::NeverOutline) {
1066 if (Opt.EnableMachineOutliner != RunOutliner::TargetDefault ||
1067 TM.Options.SupportsDefaultOutlining) {
1068 flushFPMsToMPM(PMW);
1069 addModulePass(MachineOutlinerPass(Opt.EnableMachineOutliner), PMW);
1070 }
1071 }
1072
1073 derived().addPostBBSections(PMW);
1074
1076
1077 // Add passes that directly emit MI after all other MI passes.
1078 derived().addPreEmitPass2(PMW);
1079
1080 return Error::success();
1081}
1082
1083/// Add passes that optimize machine instructions in SSA form.
1084template <typename Derived, typename TargetMachineT>
1086 PassManagerWrapper &PMW) const {
1087 // Pre-ra tail duplication.
1089
1090 // Optimize PHIs before DCE: removing dead PHI cycles may make more
1091 // instructions dead.
1093
1094 // This pass merges large allocas. StackSlotColoring is a different pass
1095 // which merges spill slots.
1097
1098 // If the target requests it, assign local variables to stack slots relative
1099 // to one another and simplify frame index references where possible.
1101
1102 // With optimization, dead code should already be eliminated. However
1103 // there is one known exception: lowered code for arguments that are only
1104 // used by tail calls, where the tail calls reuse the incoming stack
1105 // arguments directly (see t11 in test/CodeGen/X86/sibcall.ll).
1107
1108 // Allow targets to insert passes that improve instruction level parallelism,
1109 // like if-conversion. Such passes will typically need dominator trees and
1110 // loop info, just like LICM and CSE below.
1111 derived().addILPOpts(PMW);
1112
1115
1116 addMachineFunctionPass(MachineSinkingPass(Opt.EnableSinkAndFold), PMW);
1117
1119 // Clean-up the dead code that may have been generated by peephole
1120 // rewriting.
1122}
1123
1124//===---------------------------------------------------------------------===//
1125/// Register Allocation Pass Configuration
1126//===---------------------------------------------------------------------===//
1127
1128/// Instantiate the default register allocator pass for this target for either
1129/// the optimized or unoptimized allocation path. This will be added to the pass
1130/// manager by addFastRegAlloc in the unoptimized case or addOptimizedRegAlloc
1131/// in the optimized case.
1132///
1133/// A target that uses the standard regalloc pass order for fast or optimized
1134/// allocation may still override this for per-target regalloc
1135/// selection. But -regalloc-npm=... always takes precedence.
1136/// If a target does not want to allow users to set -regalloc-npm=... at all,
1137/// check if Opt.RegAlloc == RegAllocType::Unset.
1138template <typename Derived, typename TargetMachineT>
1140 PassManagerWrapper &PMW, bool Optimized) const {
1141 if (Optimized)
1143 else
1145}
1146
1147/// Find and instantiate the register allocation pass requested by this target
1148/// at the current optimization level. Different register allocators are
1149/// defined as separate passes because they may require different analysis.
1150///
1151/// This helper ensures that the -regalloc-npm= option is always available,
1152/// even for targets that override the default allocator.
1153template <typename Derived, typename TargetMachineT>
1155 PassManagerWrapper &PMW, bool Optimized) const {
1156 // Use the specified -regalloc-npm={basic|greedy|fast|pbqp}
1157 if (Opt.RegAlloc > RegAllocType::Default) {
1158 switch (Opt.RegAlloc) {
1159 case RegAllocType::Fast:
1161 break;
1164 break;
1165 default:
1166 reportFatalUsageError("register allocator not supported yet");
1167 }
1168 return;
1169 }
1170 // -regalloc=default or unspecified, so pick based on the optimization level
1171 // or ask the target for the regalloc pass.
1172 derived().addTargetRegisterAllocator(PMW, Optimized);
1173}
1174
1175template <typename Derived, typename TargetMachineT>
1177 PassManagerWrapper &PMW) const {
1178 // TODO: Ensure allocator is default or fast.
1179 addRegAllocPass(PMW, false);
1180 return Error::success();
1181}
1182
1183template <typename Derived, typename TargetMachineT>
1185 PassManagerWrapper &PMW) const {
1186 // Add the selected register allocation pass.
1187 addRegAllocPass(PMW, true);
1188
1189 // Allow targets to change the register assignments before rewriting.
1190 derived().addPreRewrite(PMW);
1191
1192 // Finally rewrite virtual registers.
1194 // Perform stack slot coloring and post-ra machine LICM.
1195 //
1196 // FIXME: Re-enable coloring with register when it's capable of adding
1197 // kill markers.
1199
1200 return Error::success();
1201}
1202
1203/// Add the minimum set of target-independent passes that are required for
1204/// register allocation. No coalescing or scheduling.
1205template <typename Derived, typename TargetMachineT>
1212
1213/// Add standard target-independent passes that are tightly coupled with
1214/// optimized register allocation, including coalescing, machine instruction
1215/// scheduling, and register allocation itself.
1216template <typename Derived, typename TargetMachineT>
1218 PassManagerWrapper &PMW) const {
1220
1222
1224
1225 // LiveVariables currently requires pure SSA form.
1226 //
1227 // FIXME: Once TwoAddressInstruction pass no longer uses kill flags,
1228 // LiveVariables can be removed completely, and LiveIntervals can be directly
1229 // computed. (We still either need to regenerate kill flags after regalloc, or
1230 // preferably fix the scavenger to not depend on them).
1231 // FIXME: UnreachableMachineBlockElim is a dependant pass of LiveVariables.
1232 // When LiveVariables is removed this has to be removed/moved either.
1233 // Explicit addition of UnreachableMachineBlockElim allows stopping before or
1234 // after it with -stop-before/-stop-after.
1238
1239 // Edge splitting is smarter with machine loop info.
1243
1244 // Eventually, we want to run LiveIntervals before PHI elimination.
1245 if (Opt.EarlyLiveIntervals)
1248
1251
1252 // The machine scheduler may accidentally create disconnected components
1253 // when moving subregister definitions around, avoid this by splitting them to
1254 // separate vregs before. Splitting can also improve reg. allocation quality.
1256
1257 // PreRA instruction scheduling.
1259
1260 if (auto E = derived().addRegAssignmentOptimized(PMW)) {
1261 // addRegAssignmentOptimized did not add a reg alloc pass, so do nothing.
1262 return;
1263 }
1264
1266
1267 // Allow targets to expand pseudo instructions depending on the choice of
1268 // registers before MachineCopyPropagation.
1269 derived().addPostRewrite(PMW);
1270
1271 // Copy propagate to forward register uses and try to eliminate COPYs that
1272 // were not coalesced.
1274
1275 // Run post-ra machine LICM to hoist reloads / remats.
1276 //
1277 // FIXME: can this move into MachineLateOptimization?
1279}
1280
1281//===---------------------------------------------------------------------===//
1282/// Post RegAlloc Pass Configuration
1283//===---------------------------------------------------------------------===//
1284
1285/// Add passes that optimize machine instructions after register allocation.
1286template <typename Derived, typename TargetMachineT>
1288 PassManagerWrapper &PMW) const {
1289 // Cleanup of redundant (identical) address/immediate loads.
1291
1292 // Branch folding must be run after regalloc and prolog/epilog insertion.
1293 addMachineFunctionPass(BranchFolderPass(Opt.EnableTailMerge), PMW);
1294
1295 // Tail duplication.
1296 // Note that duplicating tail just increases code size and degrades
1297 // performance for targets that require Structured Control Flow.
1298 // In addition it can also make CFG irreducible. Thus we disable it.
1299 if (!TM.requiresStructuredCFG())
1301
1302 // Copy propagation.
1304}
1305
1306/// Add standard basic block placement passes.
1307template <typename Derived, typename TargetMachineT>
1309 PassManagerWrapper &PMW) const {
1311 // Run a separate pass to collect block placement statistics.
1312 if (Opt.EnableBlockPlacementStats)
1314}
1315
1316} // namespace llvm
1317
1318#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:94
@ 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
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
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:177
Global function merging pass for new pass manager.
A utility pass template to force an analysis result to be available.