LLVM  13.0.0git
Classes | Public Member Functions | List of all members
llvm::PassBuilder Class Reference

This class provides access to building LLVM's passes. More...

#include "llvm/Passes/PassBuilder.h"

Classes

class  OptimizationLevel
 LLVM-provided high-level optimization levels. More...
 
struct  PipelineElement
 A struct to capture parsed pass pipeline names. More...
 

Public Member Functions

 PassBuilder (TargetMachine *TM=nullptr, PipelineTuningOptions PTO=PipelineTuningOptions(), Optional< PGOOptions > PGOOpt=None, PassInstrumentationCallbacks *PIC=nullptr)
 
void crossRegisterProxies (LoopAnalysisManager &LAM, FunctionAnalysisManager &FAM, CGSCCAnalysisManager &CGAM, ModuleAnalysisManager &MAM)
 Cross register the analysis managers through their proxies. More...
 
void registerModuleAnalyses (ModuleAnalysisManager &MAM)
 Registers all available module analysis passes. More...
 
void registerCGSCCAnalyses (CGSCCAnalysisManager &CGAM)
 Registers all available CGSCC analysis passes. More...
 
void registerFunctionAnalyses (FunctionAnalysisManager &FAM)
 Registers all available function analysis passes. More...
 
void registerLoopAnalyses (LoopAnalysisManager &LAM)
 Registers all available loop analysis passes. More...
 
FunctionPassManager buildFunctionSimplificationPipeline (OptimizationLevel Level, ThinOrFullLTOPhase Phase)
 Construct the core LLVM function canonicalization and simplification pipeline. More...
 
ModulePassManager buildModuleSimplificationPipeline (OptimizationLevel Level, ThinOrFullLTOPhase Phase)
 Construct the core LLVM module canonicalization and simplification pipeline. More...
 
ModuleInlinerWrapperPass buildInlinerPipeline (OptimizationLevel Level, ThinOrFullLTOPhase Phase)
 Construct the module pipeline that performs inlining as well as the inlining-driven cleanups. More...
 
ModulePassManager buildModuleOptimizationPipeline (OptimizationLevel Level, bool LTOPreLink=false)
 Construct the core LLVM module optimization pipeline. More...
 
ModulePassManager buildPerModuleDefaultPipeline (OptimizationLevel Level, bool LTOPreLink=false)
 Build a per-module default optimization pipeline. More...
 
ModulePassManager buildThinLTOPreLinkDefaultPipeline (OptimizationLevel Level)
 Build a pre-link, ThinLTO-targeting default optimization pipeline to a pass manager. More...
 
ModulePassManager buildThinLTODefaultPipeline (OptimizationLevel Level, const ModuleSummaryIndex *ImportSummary)
 Build an ThinLTO default optimization pipeline to a pass manager. More...
 
ModulePassManager buildLTOPreLinkDefaultPipeline (OptimizationLevel Level)
 Build a pre-link, LTO-targeting default optimization pipeline to a pass manager. More...
 
ModulePassManager buildLTODefaultPipeline (OptimizationLevel Level, ModuleSummaryIndex *ExportSummary)
 Build an LTO default optimization pipeline to a pass manager. More...
 
ModulePassManager buildO0DefaultPipeline (OptimizationLevel Level, bool LTOPreLink=false)
 Build an O0 pipeline with the minimal semantically required passes. More...
 
AAManager buildDefaultAAPipeline ()
 Build the default AAManager with the default alias analysis pipeline registered. More...
 
Error parsePassPipeline (ModulePassManager &MPM, StringRef PipelineText)
 Parse a textual pass pipeline description into a ModulePassManager. More...
 
Error parsePassPipeline (CGSCCPassManager &CGPM, StringRef PipelineText)
 {{@ Parse a textual pass pipeline description into a specific PassManager More...
 
Error parsePassPipeline (FunctionPassManager &FPM, StringRef PipelineText)
 
Error parsePassPipeline (LoopPassManager &LPM, StringRef PipelineText)
 
Error parseAAPipeline (AAManager &AA, StringRef PipelineText)
 Parse a textual alias analysis pipeline into the provided AA manager. More...
 
bool isAAPassName (StringRef PassName)
 Returns true if the pass name is the name of an alias analysis pass. More...
 
bool isAnalysisPassName (StringRef PassName)
 Returns true if the pass name is the name of a (non-alias) analysis pass. More...
 
void printPassNames (raw_ostream &OS)
 Print pass names. More...
 
void registerPeepholeEPCallback (const std::function< void(FunctionPassManager &, OptimizationLevel)> &C)
 Register a callback for a default optimizer pipeline extension point. More...
 
void registerLateLoopOptimizationsEPCallback (const std::function< void(LoopPassManager &, OptimizationLevel)> &C)
 Register a callback for a default optimizer pipeline extension point. More...
 
void registerLoopOptimizerEndEPCallback (const std::function< void(LoopPassManager &, OptimizationLevel)> &C)
 Register a callback for a default optimizer pipeline extension point. More...
 
void registerScalarOptimizerLateEPCallback (const std::function< void(FunctionPassManager &, OptimizationLevel)> &C)
 Register a callback for a default optimizer pipeline extension point. More...
 
void registerCGSCCOptimizerLateEPCallback (const std::function< void(CGSCCPassManager &, OptimizationLevel)> &C)
 Register a callback for a default optimizer pipeline extension point. More...
 
void registerVectorizerStartEPCallback (const std::function< void(FunctionPassManager &, OptimizationLevel)> &C)
 Register a callback for a default optimizer pipeline extension point. More...
 
void registerPipelineStartEPCallback (const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
 Register a callback for a default optimizer pipeline extension point. More...
 
void registerPipelineEarlySimplificationEPCallback (const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
 Register a callback for a default optimizer pipeline extension point. More...
 
void registerOptimizerLastEPCallback (const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
 Register a callback for a default optimizer pipeline extension point. More...
 
void registerParseAACallback (const std::function< bool(StringRef Name, AAManager &AA)> &C)
 Register a callback for parsing an AliasAnalysis Name to populate the given AAManager AA. More...
 
void registerAnalysisRegistrationCallback (const std::function< void(CGSCCAnalysisManager &)> &C)
 {{@ Register callbacks for analysis registration with this PassBuilder instance. More...
 
void registerAnalysisRegistrationCallback (const std::function< void(FunctionAnalysisManager &)> &C)
 
void registerAnalysisRegistrationCallback (const std::function< void(LoopAnalysisManager &)> &C)
 
void registerAnalysisRegistrationCallback (const std::function< void(ModuleAnalysisManager &)> &C)
 
void registerPipelineParsingCallback (const std::function< bool(StringRef Name, CGSCCPassManager &, ArrayRef< PipelineElement >)> &C)
 {{@ Register pipeline parsing callbacks with this pass builder instance. More...
 
void registerPipelineParsingCallback (const std::function< bool(StringRef Name, FunctionPassManager &, ArrayRef< PipelineElement >)> &C)
 
void registerPipelineParsingCallback (const std::function< bool(StringRef Name, LoopPassManager &, ArrayRef< PipelineElement >)> &C)
 
void registerPipelineParsingCallback (const std::function< bool(StringRef Name, ModulePassManager &, ArrayRef< PipelineElement >)> &C)
 
void registerParseTopLevelPipelineCallback (const std::function< bool(ModulePassManager &, ArrayRef< PipelineElement >)> &C)
 Register a callback for a top-level pipeline entry. More...
 
void addPGOInstrPassesForO0 (ModulePassManager &MPM, bool RunProfileGen, bool IsCS, std::string ProfileFile, std::string ProfileRemappingFile)
 Add PGOInstrumenation passes for O0 only. More...
 
PassInstrumentationCallbacksgetPassInstrumentationCallbacks () const
 Returns PIC. More...
 

Detailed Description

This class provides access to building LLVM's passes.

Its members provide the baseline state available to passes during their construction. The PassRegistry.def file specifies how to construct all of the built-in passes, and those may reference these members during construction.

Definition at line 139 of file PassBuilder.h.

Constructor & Destructor Documentation

◆ PassBuilder()

PassBuilder::PassBuilder ( TargetMachine TM = nullptr,
PipelineTuningOptions  PTO = PipelineTuningOptions(),
Optional< PGOOptions PGOOpt = None,
PassInstrumentationCallbacks PIC = nullptr 
)
explicit

Definition at line 450 of file PassBuilder.cpp.

References PIC, and TM.

Member Function Documentation

◆ addPGOInstrPassesForO0()

void PassBuilder::addPGOInstrPassesForO0 ( ModulePassManager MPM,
bool  RunProfileGen,
bool  IsCS,
std::string  ProfileFile,
std::string  ProfileRemappingFile 
)

Add PGOInstrumenation passes for O0 only.

Definition at line 939 of file PassBuilder.cpp.

References llvm::PassManager< IRUnitT, AnalysisManagerT, ExtraArgTs >::addPass(), assert(), MPM, and Options.

Referenced by buildO0DefaultPipeline().

◆ buildDefaultAAPipeline()

AAManager PassBuilder::buildDefaultAAPipeline ( )

Build the default AAManager with the default alias analysis pipeline registered.

This also adds target-specific alias analyses registered via TargetMachine::registerDefaultAliasAnalyses().

Definition at line 2012 of file PassBuilder.cpp.

References llvm::TargetMachine::registerDefaultAliasAnalyses(), llvm::AAManager::registerFunctionAnalysis(), and llvm::AAManager::registerModuleAnalysis().

Referenced by parseAAPipeline().

◆ buildFunctionSimplificationPipeline()

FunctionPassManager PassBuilder::buildFunctionSimplificationPipeline ( OptimizationLevel  Level,
ThinOrFullLTOPhase  Phase 
)

Construct the core LLVM function canonicalization and simplification pipeline.

This is a long pipeline and uses most of the per-function optimization passes in LLVM to canonicalize and simplify the IR. It is suitable to run repeatedly over the IR and is not expected to destroy important information about the semantics of the IR.

Note that Level cannot be O0 here. The pipelines produced are only intended for use when attempting to optimize code. If frontends require some transformations for semantic reasons, they should explicitly build them.

Phase indicates the current ThinLTO phase.

Definition at line 670 of file PassBuilder.cpp.

References llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::addPass(), llvm::PassManager< IRUnitT, AnalysisManagerT, ExtraArgTs >::addPass(), assert(), llvm::PipelineTuningOptions::Coroutines, llvm::createFunctionToLoopPassAdaptor(), llvm::EnableCHR, llvm::EnableConstraintElimination, llvm::EnableGVNHoist, llvm::EnableGVNSink, llvm::EnableKnowledgeRetention, llvm::EnableLoopFlatten, llvm::EnableLoopInterchange, llvm::EnableMSSALoopDependency, EnableO3NonTrivialUnswitching, llvm::PipelineTuningOptions::ForgetAllSCEVInLoopUnroll, llvm::PGOOptions::IRUse, isLTOPreLink(), llvm::PipelineTuningOptions::LicmMssaNoAccForPromotionCap, llvm::PipelineTuningOptions::LicmMssaOptCap, llvm::PipelineTuningOptions::LoopUnrolling, move, llvm::PassBuilder::OptimizationLevel::O0, llvm::PassBuilder::OptimizationLevel::O3, llvm::PassBuilder::OptimizationLevel::Oz, Phase, llvm::RunNewGVN, llvm::PGOOptions::SampleUse, and llvm::ThinLTOPreLink.

Referenced by buildInlinerPipeline().

◆ buildInlinerPipeline()

ModuleInlinerWrapperPass PassBuilder::buildInlinerPipeline ( OptimizationLevel  Level,
ThinOrFullLTOPhase  Phase 
)

◆ buildLTODefaultPipeline()

ModulePassManager PassBuilder::buildLTODefaultPipeline ( OptimizationLevel  Level,
ModuleSummaryIndex ExportSummary 
)

Build an LTO default optimization pipeline to a pass manager.

This provides a good default optimization pipeline for link-time optimization and code generation. It is particularly tuned to fit well when IR coming into the LTO phase was first run through addPreLinkLTODefaultPipeline, and the two coordinate closely.

Note that Level cannot be O0 here. The pipelines produced are only intended for use when attempting to optimize code. If frontends require some transformations for semantic reasons, they should explicitly build them.

Definition at line 1657 of file PassBuilder.cpp.

References addAnnotationRemarksPass(), llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::addPass(), llvm::PassManager< IRUnitT, AnalysisManagerT, ExtraArgTs >::addPass(), llvm::createFunctionToLoopPassAdaptor(), llvm::createModuleToFunctionPassAdaptor(), llvm::createModuleToPostOrderCGSCCPassAdaptor(), llvm::PGOOptions::CSIRInstr, llvm::PGOOptions::CSIRUse, llvm::EnableConstraintElimination, llvm::EnableHotColdSplit, llvm::EnableLoopFlatten, llvm::EnableMSSALoopDependency, llvm::PipelineTuningOptions::ForgetAllSCEVInLoopUnroll, llvm::FullLTOPostLink, getInlineParamsFromOptLevel(), llvm::PipelineTuningOptions::LicmMssaNoAccForPromotionCap, llvm::PipelineTuningOptions::LicmMssaOptCap, llvm::PipelineTuningOptions::LoopUnrolling, llvm::PipelineTuningOptions::MergeFunctions, move, MPM, llvm::PassBuilder::OptimizationLevel::O0, llvm::PassBuilder::OptimizationLevel::O1, llvm::PassBuilder::OptimizationLevel::O3, llvm::RunNewGVN, and llvm::PGOOptions::SampleUse.

◆ buildLTOPreLinkDefaultPipeline()

ModulePassManager PassBuilder::buildLTOPreLinkDefaultPipeline ( OptimizationLevel  Level)

Build a pre-link, LTO-targeting default optimization pipeline to a pass manager.

This adds the pre-link optimizations tuned to work well with a later LTO run. It works to minimize the IR which needs to be analyzed without making irreversible decisions which could be made better during the LTO run.

Note that Level cannot be O0 here. The pipelines produced are only intended for use when attempting to optimize code. If frontends require some transformations for semantic reasons, they should explicitly build them.

Definition at line 1648 of file PassBuilder.cpp.

References assert(), buildPerModuleDefaultPipeline(), and llvm::PassBuilder::OptimizationLevel::O0.

◆ buildModuleOptimizationPipeline()

ModulePassManager PassBuilder::buildModuleOptimizationPipeline ( OptimizationLevel  Level,
bool  LTOPreLink = false 
)

Construct the core LLVM module optimization pipeline.

This pipeline focuses on optimizing the execution speed of the IR. It uses cost modeling and thresholds to balance code growth against runtime improvements. It includes vectorization and other information destroying transformations. It also cannot generally be run repeatedly on a module without potentially seriously regressing either runtime performance of the code or serious code size growth.

Note that Level cannot be O0 here. The pipelines produced are only intended for use when attempting to optimize code. If frontends require some transformations for semantic reasons, they should explicitly build them.

Definition at line 1326 of file PassBuilder.cpp.

References llvm::PassManager< IRUnitT, AnalysisManagerT, ExtraArgTs >::addPass(), llvm::PipelineTuningOptions::CallGraphProfile, llvm::PipelineTuningOptions::Coroutines, llvm::createFunctionToLoopPassAdaptor(), llvm::createModuleToFunctionPassAdaptor(), llvm::PGOOptions::CSIRInstr, llvm::PGOOptions::CSIRUse, llvm::EnableHotColdSplit, llvm::EnableIROutliner, llvm::EnableMatrix, llvm::EnableMSSALoopDependency, llvm::EnableOrderFileInstrumentation, llvm::PipelineTuningOptions::MergeFunctions, move, MPM, llvm::PassBuilder::OptimizationLevel::Oz, and llvm::RunPartialInlining.

Referenced by buildPerModuleDefaultPipeline(), and buildThinLTODefaultPipeline().

◆ buildModuleSimplificationPipeline()

ModulePassManager PassBuilder::buildModuleSimplificationPipeline ( OptimizationLevel  Level,
ThinOrFullLTOPhase  Phase 
)

Construct the core LLVM module canonicalization and simplification pipeline.

This pipeline focuses on canonicalizing and simplifying the entire module of IR. Much like the function simplification pipeline above, it is suitable to run repeatedly over the IR and is not expected to destroy important information. It does, however, perform inlining and other heuristic based simplifications that are not strictly reversible.

Note that Level cannot be O0 here. The pipelines produced are only intended for use when attempting to optimize code. If frontends require some transformations for semantic reasons, they should explicitly build them.

Phase indicates the current ThinLTO phase.

Definition at line 1039 of file PassBuilder.cpp.

References llvm::PassManager< IRUnitT, AnalysisManagerT, ExtraArgTs >::addPass(), llvm::AttributorRun, buildInlinerPipeline(), llvm::PipelineTuningOptions::Coroutines, llvm::createModuleToFunctionPassAdaptor(), llvm::PGOOptions::CSIRInstr, DoNotRerunFunctionPasses, EnableMemProfiler, EnableSyntheticCounts, llvm::FlattenedProfileUsed, llvm::FullLTOPreLink, llvm::PGOOptions::IRInstr, llvm::PGOOptions::IRUse, llvm::MODULE, move, MPM, llvm::PassBuilder::OptimizationLevel::O2, llvm::PassBuilder::OptimizationLevel::O3, Phase, llvm::PGOOptions::SampleUse, llvm::ThinLTOPostLink, and llvm::ThinLTOPreLink.

Referenced by buildPerModuleDefaultPipeline(), buildThinLTODefaultPipeline(), and buildThinLTOPreLinkDefaultPipeline().

◆ buildO0DefaultPipeline()

ModulePassManager PassBuilder::buildO0DefaultPipeline ( OptimizationLevel  Level,
bool  LTOPreLink = false 
)

◆ buildPerModuleDefaultPipeline()

ModulePassManager PassBuilder::buildPerModuleDefaultPipeline ( OptimizationLevel  Level,
bool  LTOPreLink = false 
)

Build a per-module default optimization pipeline.

This provides a good default optimization pipeline for per-module optimization and code generation without any link-time optimization. It typically correspond to frontend "-O[123]" options for optimization levels O1, O2 and O3 resp.

Note that Level cannot be O0 here. The pipelines produced are only intended for use when attempting to optimize code. If frontends require some transformations for semantic reasons, they should explicitly build them.

Definition at line 1490 of file PassBuilder.cpp.

References addAnnotationRemarksPass(), llvm::PassManager< IRUnitT, AnalysisManagerT, ExtraArgTs >::addPass(), assert(), buildModuleOptimizationPipeline(), buildModuleSimplificationPipeline(), llvm::createModuleToFunctionPassAdaptor(), llvm::FullLTOPreLink, MPM, llvm::None, and llvm::PassBuilder::OptimizationLevel::O0.

Referenced by buildLTOPreLinkDefaultPipeline().

◆ buildThinLTODefaultPipeline()

ModulePassManager PassBuilder::buildThinLTODefaultPipeline ( OptimizationLevel  Level,
const ModuleSummaryIndex ImportSummary 
)

Build an ThinLTO default optimization pipeline to a pass manager.

This provides a good default optimization pipeline for link-time optimization and code generation. It is particularly tuned to fit well when IR coming into the LTO phase was first run through addPreLinkLTODefaultPipeline, and the two coordinate closely.

Note that Level cannot be O0 here. The pipelines produced are only intended for use when attempting to optimize code. If frontends require some transformations for semantic reasons, they should explicitly build them.

Definition at line 1592 of file PassBuilder.cpp.

References addAnnotationRemarksPass(), llvm::PassManager< IRUnitT, AnalysisManagerT, ExtraArgTs >::addPass(), buildModuleOptimizationPipeline(), buildModuleSimplificationPipeline(), MPM, llvm::PassBuilder::OptimizationLevel::O0, and llvm::ThinLTOPostLink.

◆ buildThinLTOPreLinkDefaultPipeline()

ModulePassManager PassBuilder::buildThinLTOPreLinkDefaultPipeline ( OptimizationLevel  Level)

Build a pre-link, ThinLTO-targeting default optimization pipeline to a pass manager.

This adds the pre-link optimizations tuned to prepare a module for a ThinLTO run. It works to minimize the IR which needs to be analyzed without making irreversible decisions which could be made better during the LTO run.

Note that Level cannot be O0 here. The pipelines produced are only intended for use when attempting to optimize code. If frontends require some transformations for semantic reasons, they should explicitly build them.

Definition at line 1531 of file PassBuilder.cpp.

References addAnnotationRemarksPass(), llvm::PassManager< IRUnitT, AnalysisManagerT, ExtraArgTs >::addPass(), assert(), buildModuleSimplificationPipeline(), llvm::PipelineTuningOptions::Coroutines, llvm::createModuleToFunctionPassAdaptor(), MPM, llvm::PassBuilder::OptimizationLevel::O0, llvm::RunPartialInlining, and llvm::ThinLTOPreLink.

◆ crossRegisterProxies()

void PassBuilder::crossRegisterProxies ( LoopAnalysisManager LAM,
FunctionAnalysisManager FAM,
CGSCCAnalysisManager CGAM,
ModuleAnalysisManager MAM 
)

Cross register the analysis managers through their proxies.

This is an interface that can be used to cross register each AnalysisManager with all the others analysis managers.

Definition at line 2989 of file PassBuilder.cpp.

References CGAM, FAM, LAM, MAM, and llvm::AnalysisManager< IRUnitT, ExtraArgTs >::registerPass().

◆ getPassInstrumentationCallbacks()

PassInstrumentationCallbacks* llvm::PassBuilder::getPassInstrumentationCallbacks ( ) const
inline

Returns PIC.

External libraries can use this to register pass instrumentation callbacks.

Definition at line 700 of file PassBuilder.h.

References PIC.

◆ isAAPassName()

bool PassBuilder::isAAPassName ( StringRef  PassName)

Returns true if the pass name is the name of an alias analysis pass.

Definition at line 3134 of file PassBuilder.cpp.

◆ isAnalysisPassName()

bool PassBuilder::isAnalysisPassName ( StringRef  PassName)

Returns true if the pass name is the name of a (non-alias) analysis pass.

Definition at line 3145 of file PassBuilder.cpp.

◆ parseAAPipeline()

Error PassBuilder::parseAAPipeline ( AAManager AA,
StringRef  PipelineText 
)

Parse a textual alias analysis pipeline into the provided AA manager.

The format of the textual AA pipeline is a comma separated list of AA pass names:

basic-aa,globals-aa,...

The AA manager is set up such that the provided alias analyses are tried in the order specified. See the AAManaager documentation for details about the logic used. This routine just provides the textual mapping between AA names and the analyses to register with the manager.

Returns false if the text cannot be parsed cleanly. The specific state of the AA manager is unspecified if such an error is encountered and this returns false.

Definition at line 3114 of file PassBuilder.cpp.

References buildDefaultAAPipeline(), llvm::StringRef::empty(), llvm::formatv(), llvm::inconvertibleErrorCode(), llvm::StringRef::split(), and llvm::Error::success().

◆ parsePassPipeline() [1/4]

Error PassBuilder::parsePassPipeline ( CGSCCPassManager CGPM,
StringRef  PipelineText 
)

{{@ Parse a textual pass pipeline description into a specific PassManager

Automatic deduction of an appropriate pass manager stack is not supported. For example, to insert a loop pass 'lpass' into a FunctionPassManager, this is the valid pipeline text:

function(lpass)

Definition at line 3055 of file PassBuilder.cpp.

References llvm::formatv(), llvm::StringRef::front(), llvm::inconvertibleErrorCode(), and isCGSCCPassName().

◆ parsePassPipeline() [2/4]

Error PassBuilder::parsePassPipeline ( FunctionPassManager FPM,
StringRef  PipelineText 
)

◆ parsePassPipeline() [3/4]

Error PassBuilder::parsePassPipeline ( LoopPassManager LPM,
StringRef  PipelineText 
)

Definition at line 3100 of file PassBuilder.cpp.

References llvm::formatv(), and llvm::inconvertibleErrorCode().

◆ parsePassPipeline() [4/4]

Error PassBuilder::parsePassPipeline ( ModulePassManager MPM,
StringRef  PipelineText 
)

Parse a textual pass pipeline description into a ModulePassManager.

The format of the textual pass pipeline description looks something like:

module(function(instcombine,sroa),dce,cgscc(inliner,function(...)),...)

Pass managers have ()s describing the nest structure of passes. All passes are comma separated. As a special shortcut, if the very first pass is not a module pass (as a module pass manager is), this will automatically form the shortest stack of pass managers that allow inserting that first pass. So, assuming function passes 'fpassN', CGSCC passes 'cgpassN', and loop passes 'lpassN', all of these are valid:

fpass1,fpass2,fpass3 cgpass1,cgpass2,cgpass3 lpass1,lpass2,lpass3

And they are equivalent to the following (resp.):

module(function(fpass1,fpass2,fpass3)) module(cgscc(cgpass1,cgpass2,cgpass3)) module(function(loop(lpass1,lpass2,lpass3)))

This shortcut is especially useful for debugging and testing small pass combinations.

The sequence of passes aren't necessarily the exact same kind of pass. You can mix different levels implicitly if adaptor passes are defined to make them work. For example,

mpass1,fpass1,fpass2,mpass2,lpass1

This pipeline uses only one pass manager: the top-level module manager. fpass1,fpass2 and lpass1 are added into the the top-level module manager using only adaptor passes. No nested function/loop pass managers are added. The purpose is to allow easy pass testing when the user specifically want the pass to run under a adaptor directly. This is preferred when a pipeline is largely of one type, but one or just a few passes are of different types(See PassBuilder.cpp for examples).

Definition at line 3014 of file PassBuilder.cpp.

References llvm::formatv(), llvm::StringRef::front(), llvm::inconvertibleErrorCode(), isCGSCCPassName(), isFunctionPassName(), isLoopPassName(), isModulePassName(), move, MPM, and llvm::Error::success().

◆ printPassNames()

void PassBuilder::printPassNames ( raw_ostream OS)

Print pass names.

Definition at line 3172 of file PassBuilder.cpp.

◆ registerAnalysisRegistrationCallback() [1/4]

void llvm::PassBuilder::registerAnalysisRegistrationCallback ( const std::function< void(CGSCCAnalysisManager &)> &  C)
inline

{{@ Register callbacks for analysis registration with this PassBuilder instance.

Callees register their analyses with the given AnalysisManager objects.

Definition at line 640 of file PassBuilder.h.

Referenced by llvm::AMDGPUTargetMachine::registerPassBuilderCallbacks().

◆ registerAnalysisRegistrationCallback() [2/4]

void llvm::PassBuilder::registerAnalysisRegistrationCallback ( const std::function< void(FunctionAnalysisManager &)> &  C)
inline

Definition at line 644 of file PassBuilder.h.

◆ registerAnalysisRegistrationCallback() [3/4]

void llvm::PassBuilder::registerAnalysisRegistrationCallback ( const std::function< void(LoopAnalysisManager &)> &  C)
inline

Definition at line 648 of file PassBuilder.h.

◆ registerAnalysisRegistrationCallback() [4/4]

void llvm::PassBuilder::registerAnalysisRegistrationCallback ( const std::function< void(ModuleAnalysisManager &)> &  C)
inline

Definition at line 652 of file PassBuilder.h.

◆ registerCGSCCAnalyses()

void PassBuilder::registerCGSCCAnalyses ( CGSCCAnalysisManager CGAM)

Registers all available CGSCC analysis passes.

This is an interface that can be used to populate a CGSCCAnalysisManager with all registered CGSCC analyses. Callers can still manually register any additional analyses. Callers can also pre-register analyses and this will not override those.

Definition at line 492 of file PassBuilder.cpp.

References CGAM.

◆ registerCGSCCOptimizerLateEPCallback()

void llvm::PassBuilder::registerCGSCCOptimizerLateEPCallback ( const std::function< void(CGSCCPassManager &, OptimizationLevel)> &  C)
inline

Register a callback for a default optimizer pipeline extension point.

This extension point allows adding CallGraphSCC passes at the end of the main CallGraphSCC passes and before any function simplification passes run by CGPassManager.

Definition at line 586 of file PassBuilder.h.

Referenced by llvm::AMDGPUTargetMachine::registerPassBuilderCallbacks().

◆ registerFunctionAnalyses()

void PassBuilder::registerFunctionAnalyses ( FunctionAnalysisManager FAM)

Registers all available function analysis passes.

This is an interface that can be used to populate a FunctionAnalysisManager with all registered function analyses. Callers can still manually register any additional analyses. Callers can also pre-register analyses and this will not override those.

Definition at line 501 of file PassBuilder.cpp.

References FAM.

Referenced by llvm::orc::BlockFreqQuery::operator()().

◆ registerLateLoopOptimizationsEPCallback()

void llvm::PassBuilder::registerLateLoopOptimizationsEPCallback ( const std::function< void(LoopPassManager &, OptimizationLevel)> &  C)
inline

Register a callback for a default optimizer pipeline extension point.

This extension point allows adding late loop canonicalization and simplification passes. This is the last point in the loop optimization pipeline before loop deletion. Each pass added here must be an instance of LoopPass. This is the place to add passes that can remove loops, such as target- specific loop idiom recognition.

Definition at line 555 of file PassBuilder.h.

Referenced by llvm::HexagonTargetMachine::registerPassBuilderCallbacks().

◆ registerLoopAnalyses()

void PassBuilder::registerLoopAnalyses ( LoopAnalysisManager LAM)

Registers all available loop analysis passes.

This is an interface that can be used to populate a LoopAnalysisManager with all registered loop analyses. Callers can still manually register any additional analyses.

Definition at line 510 of file PassBuilder.cpp.

References LAM.

◆ registerLoopOptimizerEndEPCallback()

void llvm::PassBuilder::registerLoopOptimizerEndEPCallback ( const std::function< void(LoopPassManager &, OptimizationLevel)> &  C)
inline

Register a callback for a default optimizer pipeline extension point.

This extension point allows adding loop passes to the end of the loop optimizer.

Definition at line 565 of file PassBuilder.h.

Referenced by llvm::HexagonTargetMachine::registerPassBuilderCallbacks().

◆ registerModuleAnalyses()

void PassBuilder::registerModuleAnalyses ( ModuleAnalysisManager MAM)

Registers all available module analysis passes.

This is an interface that can be used to populate a ModuleAnalysisManager with all registered module analyses. Callers can still manually register any additional analyses. Callers can also pre-register analyses and this will not override those.

Definition at line 483 of file PassBuilder.cpp.

References MAM.

◆ registerOptimizerLastEPCallback()

void llvm::PassBuilder::registerOptimizerLastEPCallback ( const std::function< void(ModulePassManager &, OptimizationLevel)> &  C)
inline

Register a callback for a default optimizer pipeline extension point.

This extension point allows adding optimizations at the very end of the function optimization pipeline.

Definition at line 625 of file PassBuilder.h.

◆ registerParseAACallback()

void llvm::PassBuilder::registerParseAACallback ( const std::function< bool(StringRef Name, AAManager &AA)> &  C)
inline

Register a callback for parsing an AliasAnalysis Name to populate the given AAManager AA.

Definition at line 632 of file PassBuilder.h.

Referenced by llvm::AMDGPUTargetMachine::registerPassBuilderCallbacks().

◆ registerParseTopLevelPipelineCallback()

void PassBuilder::registerParseTopLevelPipelineCallback ( const std::function< bool(ModulePassManager &, ArrayRef< PipelineElement >)> &  C)

Register a callback for a top-level pipeline entry.

If the PassManager type is not given at the top level of the pipeline text, this Callback should be used to determine the appropriate stack of PassManagers and populate the passed ModulePassManager.

Definition at line 3216 of file PassBuilder.cpp.

◆ registerPeepholeEPCallback()

void llvm::PassBuilder::registerPeepholeEPCallback ( const std::function< void(FunctionPassManager &, OptimizationLevel)> &  C)
inline

Register a callback for a default optimizer pipeline extension point.

This extension point allows adding passes that perform peephole optimizations similar to the instruction combiner. These passes will be inserted after each instance of the instruction combiner pass.

Definition at line 541 of file PassBuilder.h.

Referenced by llvm::BPFTargetMachine::registerPassBuilderCallbacks().

◆ registerPipelineEarlySimplificationEPCallback()

void llvm::PassBuilder::registerPipelineEarlySimplificationEPCallback ( const std::function< void(ModulePassManager &, OptimizationLevel)> &  C)
inline

Register a callback for a default optimizer pipeline extension point.

This extension point allows adding optimization right after passes that do basic simplification of the input IR.

Definition at line 616 of file PassBuilder.h.

Referenced by llvm::BPFTargetMachine::registerPassBuilderCallbacks(), and llvm::AMDGPUTargetMachine::registerPassBuilderCallbacks().

◆ registerPipelineParsingCallback() [1/4]

void llvm::PassBuilder::registerPipelineParsingCallback ( const std::function< bool(StringRef Name, CGSCCPassManager &, ArrayRef< PipelineElement >)> &  C)
inline

{{@ Register pipeline parsing callbacks with this pass builder instance.

Using these callbacks, callers can parse both a single pass name, as well as entire sub-pipelines, and populate the PassManager instance accordingly.

Definition at line 662 of file PassBuilder.h.

Referenced by llvm::AMDGPUTargetMachine::registerPassBuilderCallbacks(), and llvm::NVPTXTargetMachine::registerPassBuilderCallbacks().

◆ registerPipelineParsingCallback() [2/4]

void llvm::PassBuilder::registerPipelineParsingCallback ( const std::function< bool(StringRef Name, FunctionPassManager &, ArrayRef< PipelineElement >)> &  C)
inline

Definition at line 667 of file PassBuilder.h.

◆ registerPipelineParsingCallback() [3/4]

void llvm::PassBuilder::registerPipelineParsingCallback ( const std::function< bool(StringRef Name, LoopPassManager &, ArrayRef< PipelineElement >)> &  C)
inline

Definition at line 672 of file PassBuilder.h.

◆ registerPipelineParsingCallback() [4/4]

void llvm::PassBuilder::registerPipelineParsingCallback ( const std::function< bool(StringRef Name, ModulePassManager &, ArrayRef< PipelineElement >)> &  C)
inline

Definition at line 677 of file PassBuilder.h.

◆ registerPipelineStartEPCallback()

void llvm::PassBuilder::registerPipelineStartEPCallback ( const std::function< void(ModulePassManager &, OptimizationLevel)> &  C)
inline

Register a callback for a default optimizer pipeline extension point.

This extension point allows adding optimization once at the start of the pipeline. This does not apply to 'backend' compiles (LTO and ThinLTO link-time pipelines).

Definition at line 607 of file PassBuilder.h.

Referenced by llvm::BPFTargetMachine::registerPassBuilderCallbacks(), llvm::AMDGPUTargetMachine::registerPassBuilderCallbacks(), and llvm::NVPTXTargetMachine::registerPassBuilderCallbacks().

◆ registerScalarOptimizerLateEPCallback()

void llvm::PassBuilder::registerScalarOptimizerLateEPCallback ( const std::function< void(FunctionPassManager &, OptimizationLevel)> &  C)
inline

Register a callback for a default optimizer pipeline extension point.

This extension point allows adding optimization passes after most of the main optimizations, but before the last cleanup-ish optimizations.

Definition at line 575 of file PassBuilder.h.

◆ registerVectorizerStartEPCallback()

void llvm::PassBuilder::registerVectorizerStartEPCallback ( const std::function< void(FunctionPassManager &, OptimizationLevel)> &  C)
inline

Register a callback for a default optimizer pipeline extension point.

This extension point allows adding optimization passes before the vectorizer and other highly target specific optimization passes are executed.

Definition at line 597 of file PassBuilder.h.


The documentation for this class was generated from the following files: