133#define DUMMY_MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
134 AnalysisKey PASS_NAME::Key;
135#include "llvm/Passes/MachinePassRegistry.def"
147 if (
Opt.EnableIPRA) {
148 TM.Options.EnableIPRA = *Opt.EnableIPRA;
151 TM.Options.EnableIPRA |= TM.useIPRA();
154 if (
Opt.EnableGlobalISelAbort)
155 TM.Options.GlobalISelAbort = *
Opt.EnableGlobalISelAbort;
158 TM.setEnableTiedFastRegAlloc(
Opt.EnableRegAllocFastTied ==
164 bool Optimized = Opt.RegAlloc > RegAllocType::Default
165 ? Opt.RegAlloc != RegAllocType::Fast
166 : getOptLevel() != CodeGenOptLevel::None;
167 Opt.OptimizeRegAlloc =
168 Optimized ? cl::boolOrDefault::BOU_TRUE : cl::boolOrDefault::BOU_FALSE;
213 bool FreeMachineFunctions) {
221 if (FreeMachineFunctions)
223 if (AddInCGSCCOrder) {
237 return StartStopInfo.takeError();
238 setStartStopPasses(*StartStopInfo);
262 TM.createMCStreamer(Out, DwoOut, FileType, Ctx);
263 if (!MCStreamerOrErr)
265 std::unique_ptr<AsmPrinter>
Printer(
266 TM.getTarget().createAsmPrinter(
TM, std::move(*MCStreamerOrErr)));
279 if (PrintAsm ? !
Opt.DisableVerify &&
TM.Options.EnableDefaultMachineVerifier
294 return verifyStartStop(*StartStopInfo);
297void CodeGenPassBuilder::setStartStopPasses(
299 if (!Info.StartPass.empty()) {
301 BeforeCallbacks.emplace_back([
this, &Info, AfterFlag = Info.StartAfter,
303 if (Count == Info.StartInstanceNum) {
311 auto PassName =
PIC->getPassNameForClassName(ClassName);
313 Started = !Info.StartAfter;
319 if (!
Info.StopPass.empty()) {
321 BeforeCallbacks.emplace_back([
this, &Info, AfterFlag =
Info.StopAfter,
323 if (Count == Info.StopInstanceNum) {
333 Stopped = !
Info.StopAfter;
339Error CodeGenPassBuilder::verifyStartStop(
341 if (Started && Stopped)
346 "Can't find start pass \"" +
Info.StartPass +
"\".",
347 std::make_error_code(std::errc::invalid_argument));
350 "Can't find stop pass \"" +
Info.StopPass +
"\".",
351 std::make_error_code(std::errc::invalid_argument));
362 if (
TM.useEmulatedTLS())
385 if (!
Opt.DisableVerify)
394 if (
Opt.EnableLoopTermFold)
424 !
Opt.DisablePartialLibcallInlining)
436 if (!
Opt.DisableExpandReductions)
443 if (
Opt.EnableGlobalMergeFunc) {
455 bool HasEHPrep =
false;
510 if (
Opt.RequiresCodeGenSCCOrder && !AddInCGSCCOrder)
519 if (
Opt.PrintISelInput)
521 dbgs(),
"\n\n*** Final LLVM Code input to ISel ***\n"),
531 if (!
Opt.DisableVerify)
537 TM.setO0WantsFastISel(
Opt.EnableFastISelOption !=
542 SelectorType Selector;
545 Selector = SelectorType::FastISel;
547 (
TM.Options.EnableGlobalISel &&
549 Selector = SelectorType::GlobalISel;
551 Selector = SelectorType::FastISel;
553 Selector = SelectorType::SelectionDAG;
556 if (Selector == SelectorType::FastISel) {
557 TM.setFastISel(
true);
558 TM.setGlobalISel(
false);
559 }
else if (Selector == SelectorType::GlobalISel) {
560 TM.setFastISel(
false);
561 TM.setGlobalISel(
true);
565 if (Selector == SelectorType::GlobalISel) {
636 if (
TM.Options.EnableIPRA) {
683 if (
Opt.EnableImplicitNullChecks)
690 !
TM.targetSchedulesPostRAScheduling()) {
691 if (
Opt.MISchedPostRA)
712 if (
TM.Options.EnableIPRA) {
717 if (
Opt.PrintRegUsage) {
731 if (
TM.Options.EnableMachineOutliner &&
735 TM.supportsDefaultOutlining()) {
741 if (
Opt.EnableGCEmptyBlocks)
746 if (!
Opt.DisableCFIFixup &&
TM.Options.EnableCFIFixup)
828 switch (
Opt.RegAlloc) {
869 if (!
TM.enableTiedFastRegAlloc())
890 if (
Opt.EnableSSAMachineScheduler) {
918 if (!AddedPasses.
get())
955 if (!
TM.requiresStructuredCFG())
966 if (
Opt.EnableBlockPlacementStats)
amdgpu next use AMDGPU Next Use Analysis Printer
Contains definition of the base CFIFixup pass.
This header provides classes for managing passes over SCCs of the call graph.
Interfaces for producing common pass manager configurations.
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...
This header provides classes for managing a pipeline of passes over loops in LLVM IR.
ModuleAnalysisManager MAM
PassInstrumentationCallbacks PIC
This pass is required to take advantage of the interprocedural register allocation infrastructure.
This file contains the declaration of the ResetMachineFunctionPass class.
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.
static const char PassName[]
A pass that canonicalizes freeze instructions in a loop.
virtual void addPreEmitPass(PassManagerWrapper &PMW)
This pass may be implemented by targets that want to run passes immediately before machine code is em...
virtual void addMachineSSAOptimization(PassManagerWrapper &PMW)
Methods with trivial inline returns are convenient points in the common codegen pass pipeline where t...
void addRegAllocPass(PassManagerWrapper &PMW, bool Optimized)
addMachinePasses helper to create the target-selected or overriden regalloc pass.
void addMachineFunctionPass(PassT &&Pass, PassManagerWrapper &PMW, bool Force=false, StringRef Name=PassT::name())
CodeGenPassBuilder(TargetMachine &TM, const CGPassBuilderOption &Opts, PassInstrumentationCallbacks *PIC)
virtual Error addLegalizeMachineIR(PassManagerWrapper &PMW)
This method should install a legalize pass, which converts the instruction sequence into one that can...
virtual void addPreRewrite(PassManagerWrapper &PMW)
addPreRewrite - Add passes to the optimized register allocation pipeline after register allocation is...
virtual Error addMachinePasses(PassManagerWrapper &PMW)
Add the complete, standard set of LLVM CodeGen passes.
void flushFPMsToMPM(PassManagerWrapper &PMW, bool FreeMachineFunctions=false)
virtual void addAsmPrinter(PassManagerWrapper &PMW)
virtual Error addRegAssignAndRewriteFast(PassManagerWrapper &PMW)
Add core register allocator passes which do the actual register assignment and rewriting.
void addFunctionPass(PassT &&Pass, PassManagerWrapper &PMW, bool Force=false, StringRef Name=PassT::name())
virtual void addIRPasses(PassManagerWrapper &PMW)
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
virtual void addMachineLateOptimization(PassManagerWrapper &PMW)
Add passes that optimize machine instructions after register allocation.
Error buildPipeline(ModulePassManager &MPM, ModuleAnalysisManager &MAM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType, MCContext &Ctx)
virtual void addPreRegAlloc(PassManagerWrapper &PMW)
This method may be implemented by targets that want to run passes immediately before register allocat...
virtual ~CodeGenPassBuilder()
virtual void addPostRegAlloc(PassManagerWrapper &PMW)
This method may be implemented by targets that want to run passes after register allocation pass pipe...
bool isGlobalISelAbortEnabled() const
Check whether or not GlobalISel should abort on error.
virtual void addPreSched2(PassManagerWrapper &PMW)
This method may be implemented by targets that want to run passes after prolog-epilog insertion and b...
void addISelPasses(PassManagerWrapper &PMW)
High level function that adds all passes necessary to go from llvm IR representation to the MI repres...
virtual void addCodeGenPrepare(PassManagerWrapper &PMW)
Add pass to prepare the LLVM IR for code generation.
Error addCoreISelPasses(PassManagerWrapper &PMW)
Add the actual instruction selection passes.
virtual void addPreEmitPass2(PassManagerWrapper &PMW)
Targets may add passes immediately before machine code is emitted in this callback.
virtual void addPreRegBankSelect(PassManagerWrapper &PMW)
This method may be implemented by targets that want to run passes immediately before the register ban...
virtual bool isMachinePipelinerEnabled() const
Return true if the MachinePipeliner should run before addPreRegAlloc by default.
virtual void addGlobalMergePass(PassManagerWrapper &PMW)
Target can override this to add GlobalMergePass before all IR passes.
CodeGenOptLevel getOptLevel() const
virtual void addTargetRegisterAllocator(PassManagerWrapper &PMW, bool Optimized)
Utilities for targets to add passes to the pass manager.
virtual Error addGlobalInstructionSelect(PassManagerWrapper &PMW)
This method should install a (global) instruction selector pass, which converts possibly generic inst...
virtual void addAsmPrinterBegin(PassManagerWrapper &PMW)
virtual Error addIRTranslator(PassManagerWrapper &PMW)
This method should install an IR translator pass, which converts from LLVM code to machine instructio...
virtual void addPreLegalizeMachineIR(PassManagerWrapper &PMW)
This method may be implemented by targets that want to run passes immediately before legalization.
virtual Expected< bool > addRegAssignAndRewriteOptimized(PassManagerWrapper &PMW)
virtual void addISelPrepare(PassManagerWrapper &PMW)
Add common passes that perform LLVM IR to IR transforms in preparation for instruction selection.
virtual void addPreISel(PassManagerWrapper &PMW)
{{@ For GlobalISel
virtual Error addOptimizedRegAlloc(PassManagerWrapper &PMW)
addOptimizedRegAlloc - Add passes related to register allocation.
virtual void addPostBBSections(PassManagerWrapper &PMW)
void addModulePass(PassT &&Pass, PassManagerWrapper &PMW, bool Force=false, StringRef Name=PassT::name())
virtual Error addFastRegAlloc(PassManagerWrapper &PMW)
addFastRegAlloc - Add the minimum set of target-independent passes that are required for fast registe...
virtual void addPreGlobalInstructionSelect(PassManagerWrapper &PMW)
This method may be implemented by targets that want to run passes immediately before the (global) ins...
virtual void addPassesToHandleExceptions(PassManagerWrapper &PMW)
Add passes to lower exception handling for the code generator.
virtual void addILPOpts(PassManagerWrapper &PMW)
Add passes that optimize instruction level parallelism for out-of-order targets.
PassInstrumentationCallbacks * PIC
virtual void addAsmPrinterEnd(PassManagerWrapper &PMW)
virtual Error addInstSelector(PassManagerWrapper &PMW)
addInstSelector - This method should install an instruction selector pass, which converts from LLVM c...
virtual void addBlockPlacement(PassManagerWrapper &PMW)
Add standard basic block placement passes.
virtual void addPostRewrite(PassManagerWrapper &PMW)
Add passes to be run immediately after virtual registers are rewritten to physical registers.
bool reportDiagnosticWhenGlobalISelFallback() const
Check whether or not a diagnostic should be emitted when GlobalISel uses the fallback path.
virtual void addGCPasses(PassManagerWrapper &PMW)
addGCPasses - Add late codegen passes that analyze code for garbage collection.
void requireCGSCCOrder(PassManagerWrapper &PMW)
bool CompletesPipeline
Whether no -stop-before/-stop-after option ends the pipeline early.
virtual Error addRegBankSelect(PassManagerWrapper &PMW)
This method should install a register bank selector pass, which assigns register banks to virtual reg...
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
LowerIntrinsics - This pass rewrites calls to the llvm.gcread or llvm.gcwrite intrinsics,...
Performs Loop Strength Reduce Pass.
Context object for machine code objects.
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 (for the new pass manager) for printing a Function as LLVM's text IR assembly.
Inject MD_prof metadata where it's missing.
Checks that MD_prof is present on every instruction that supports it.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Represent a constant reference to a string, i.e.
Primary interface to the complete machine description for the target machine.
static Expected< StartStopInfo > getStartStopInfo(const TargetMachine &TM, PassInstrumentationCallbacks &PIC)
Returns pass name in -stop-before or -stop-after NOTE: New pass manager migration only.
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.
This is an optimization pass for GlobalISel generic memory operations.
ModuleToFunctionPassAdaptor createModuleToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
cl::opt< bool > EnableProfcheckInPipeline("enable-profcheck-in-pipeline", cl::init(false), cl::desc("Adds profile verification to the pipeline, erroring if profile " "information is dropped."))
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
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,...
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.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
PassManager< Function > FunctionPassManager
Convenience typedef for a pass manager over functions.
@ SjLj
setjmp/longjmp based exceptions
@ DwarfCFI
DWARF-like instruction based exceptions.
@ WinEH
Windows Exception Handling.
@ Wasm
WebAssembly Exception Handling.
PassManager< MachineFunction > MachineFunctionPassManager
Convenience typedef for a pass manager over functions.
@ End
Run the machine verifier once, at the end of the pipeline.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
Global function merging pass for new pass manager.
A utility pass template to force an analysis result to be available.