LLVM
15.0.0git
|
PassManagerBuilder - This class is used to set up a standard optimization sequence for languages like C and C++, allowing some APIs to customize the pass sequence in various ways. More...
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
Public Types | |
enum | ExtensionPointTy { EP_EarlyAsPossible, EP_ModuleOptimizerEarly, EP_LoopOptimizerEnd, EP_ScalarOptimizerLate, EP_OptimizerLast, EP_VectorizerStart, EP_EnabledOnOptLevel0, EP_Peephole, EP_LateLoopOptimizations, EP_CGSCCOptimizerLate, EP_FullLinkTimeOptimizationEarly, EP_FullLinkTimeOptimizationLast } |
typedef std::function< void(const PassManagerBuilder &Builder, legacy::PassManagerBase &PM)> | ExtensionFn |
Extensions are passed to the builder itself (so they can see how it is configured) as well as the pass manager to add stuff to. More... | |
typedef int | GlobalExtensionID |
Public Member Functions | |
PassManagerBuilder () | |
~PassManagerBuilder () | |
void | addExtension (ExtensionPointTy Ty, ExtensionFn Fn) |
void | populateFunctionPassManager (legacy::FunctionPassManager &FPM) |
populateFunctionPassManager - This fills in the function pass manager, which is expected to be run on each function immediately as it is generated. More... | |
void | populateModulePassManager (legacy::PassManagerBase &MPM) |
populateModulePassManager - This sets up the primary pass manager. More... | |
Static Public Member Functions | |
static GlobalExtensionID | addGlobalExtension (ExtensionPointTy Ty, ExtensionFn Fn) |
Adds an extension that will be used by all PassManagerBuilder instances. More... | |
static void | removeGlobalExtension (GlobalExtensionID ExtensionID) |
Removes an extension that was previously added using addGlobalExtension. More... | |
Public Attributes | |
unsigned | OptLevel |
The Optimization Level - Specify the basic optimization level. More... | |
unsigned | SizeLevel |
SizeLevel - How much we're optimizing for size. More... | |
TargetLibraryInfoImpl * | LibraryInfo |
LibraryInfo - Specifies information about the runtime library for the optimizer. More... | |
Pass * | Inliner |
Inliner - Specifies the inliner to use. More... | |
ModuleSummaryIndex * | ExportSummary = nullptr |
The module summary index to use for exporting information from the regular LTO phase, for example for the CFI and devirtualization type tests. More... | |
const ModuleSummaryIndex * | ImportSummary = nullptr |
The module summary index to use for importing information to the thin LTO backends, for example for the CFI and devirtualization type tests. More... | |
bool | DisableUnrollLoops |
bool | CallGraphProfile |
bool | SLPVectorize |
bool | LoopVectorize |
bool | LoopsInterleaved |
bool | RerollLoops |
bool | NewGVN |
bool | DisableGVNLoadPRE |
bool | ForgetAllSCEVInLoopUnroll |
bool | VerifyInput |
bool | VerifyOutput |
bool | MergeFunctions |
bool | PrepareForLTO |
bool | PrepareForThinLTO |
bool | PerformThinLTO |
bool | DivergentTarget |
unsigned | LicmMssaOptCap |
unsigned | LicmMssaNoAccForPromotionCap |
bool | EnablePGOInstrGen |
Enable profile instrumentation pass. More... | |
bool | EnablePGOCSInstrGen |
Enable profile context sensitive instrumentation pass. More... | |
bool | EnablePGOCSInstrUse |
Enable profile context sensitive profile use pass. More... | |
std::string | PGOInstrGen |
Profile data file name that the instrumentation will be written to. More... | |
std::string | PGOInstrUse |
Path of the profile data file. More... | |
std::string | PGOSampleUse |
Path of the sample Profile data file. More... | |
PassManagerBuilder - This class is used to set up a standard optimization sequence for languages like C and C++, allowing some APIs to customize the pass sequence in various ways.
A simple example of using it would be:
PassManagerBuilder Builder; Builder.OptLevel = 2; Builder.populateFunctionPassManager(FPM); Builder.populateModulePassManager(MPM);
In addition to setting up the basic passes, PassManagerBuilder allows frontends to vend a plugin API, where plugins are allowed to add extensions to the default pass manager. They do this by specifying where in the pass pipeline they want to be added, along with a callback function that adds the pass(es). For example, a plugin that wanted to add a loop optimization could do something like this:
static void addMyLoopPass(const PMBuilder &Builder, PassManagerBase &PM) { if (Builder.getOptLevel() > 2 && Builder.getOptSizeLevel() == 0) PM.add(createMyAwesomePass()); } ... Builder.addExtension(PassManagerBuilder::EP_LoopOptimizerEnd, addMyLoopPass); ...
Definition at line 57 of file PassManagerBuilder.h.
typedef std::function<void(const PassManagerBuilder &Builder, legacy::PassManagerBase &PM)> llvm::PassManagerBuilder::ExtensionFn |
Extensions are passed to the builder itself (so they can see how it is configured) as well as the pass manager to add stuff to.
Definition at line 63 of file PassManagerBuilder.h.
Definition at line 64 of file PassManagerBuilder.h.
Enumerator | |
---|---|
EP_EarlyAsPossible | EP_EarlyAsPossible - This extension point allows adding passes before any other transformations, allowing them to see the code as it is coming out of the frontend. |
EP_ModuleOptimizerEarly | EP_ModuleOptimizerEarly - This extension point allows adding passes just before the main module-level optimization passes. |
EP_LoopOptimizerEnd | EP_LoopOptimizerEnd - This extension point allows adding loop passes to the end of the loop optimizer. |
EP_ScalarOptimizerLate | EP_ScalarOptimizerLate - This extension point allows adding optimization passes after most of the main optimizations, but before the last cleanup-ish optimizations. |
EP_OptimizerLast | EP_OptimizerLast – This extension point allows adding passes that run after everything else. |
EP_VectorizerStart | EP_VectorizerStart - This extension point allows adding optimization passes before the vectorizer and other highly target specific optimization passes are executed. |
EP_EnabledOnOptLevel0 | EP_EnabledOnOptLevel0 - This extension point allows adding passes that should not be disabled by O0 optimization level. The passes will be inserted after the inlining pass. |
EP_Peephole | EP_Peephole - 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. |
EP_LateLoopOptimizations | EP_LateLoopOptimizations - 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. |
EP_CGSCCOptimizerLate | EP_CGSCCOptimizerLate - This extension point allows adding CallGraphSCC passes at the end of the main CallGraphSCC passes and before any function simplification passes run by CGPassManager. |
EP_FullLinkTimeOptimizationEarly | EP_FullLinkTimeOptimizationEarly - This extensions point allow adding passes that run at Link Time, before Full Link Time Optimization. |
EP_FullLinkTimeOptimizationLast | EP_FullLinkTimeOptimizationLast - This extensions point allow adding passes that run at Link Time, after Full Link Time Optimization. |
Definition at line 66 of file PassManagerBuilder.h.
PassManagerBuilder::PassManagerBuilder | ( | ) |
Definition at line 177 of file PassManagerBuilder.cpp.
References CallGraphProfile, DisableGVNLoadPRE, DisableUnrollLoops, DivergentTarget, llvm::EnablePerformThinLTO, EnablePGOCSInstrGen, EnablePGOCSInstrUse, EnablePGOInstrGen, llvm::EnablePrepareForThinLTO, ForgetAllSCEVInLoopUnroll, llvm::ForgetSCEVInLoopUnroll, Inliner, LibraryInfo, LicmMssaNoAccForPromotionCap, LicmMssaOptCap, LoopsInterleaved, LoopVectorize, MergeFunctions, NewGVN, OptLevel, PerformThinLTO, PGOInstrGen, PGOInstrUse, PGOSampleUse, PrepareForLTO, PrepareForThinLTO, RerollLoops, llvm::RunLoopRerolling, llvm::RunNewGVN, llvm::SetLicmMssaNoAccForPromotionCap, llvm::SetLicmMssaOptCap, SizeLevel, SLPVectorize, VerifyInput, and VerifyOutput.
PassManagerBuilder::~PassManagerBuilder | ( | ) |
Definition at line 208 of file PassManagerBuilder.cpp.
References Inliner, and LibraryInfo.
void PassManagerBuilder::addExtension | ( | ExtensionPointTy | Ty, |
ExtensionFn | Fn | ||
) |
Definition at line 254 of file PassManagerBuilder.cpp.
References move.
Referenced by llvm::HexagonTargetMachine::adjustPassManager().
|
static |
Adds an extension that will be used by all PassManagerBuilder instances.
This is intended to be used by plugins, to register a set of optimisations to run automatically.
Definition at line 230 of file PassManagerBuilder.cpp.
References GlobalExtensions, GlobalExtensionsCounter, and move.
Referenced by llvm::RegisterStandardPasses::RegisterStandardPasses().
void PassManagerBuilder::populateFunctionPassManager | ( | legacy::FunctionPassManager & | FPM | ) |
populateFunctionPassManager - This fills in the function pass manager, which is expected to be run on each function immediately as it is generated.
The idea is to reduce the size of the IR in memory.
Definition at line 295 of file PassManagerBuilder.cpp.
References llvm::legacy::FunctionPassManager::add(), llvm::createCFGSimplificationPass(), llvm::createEarlyCSEPass(), llvm::createLowerExpectIntrinsicPass(), llvm::createLowerMatrixIntrinsicsMinimalPass(), llvm::createSROAPass(), llvm::EnableMatrix, EP_EarlyAsPossible, LibraryInfo, and OptLevel.
void PassManagerBuilder::populateModulePassManager | ( | legacy::PassManagerBase & | MPM | ) |
populateModulePassManager - This sets up the primary pass manager.
Definition at line 597 of file PassManagerBuilder.cpp.
References llvm::AttributorRun, CallGraphProfile, llvm::CGSCC, llvm::createAnnotation2MetadataLegacyPass(), llvm::createAnnotationRemarksLegacyPass(), llvm::createAttributorCGSCCLegacyPass(), llvm::createAttributorLegacyPass(), llvm::createBarrierNoopPass(), llvm::createCalledValuePropagationPass(), llvm::createCallSiteSplittingPass(), llvm::createCanonicalizeAliasesPass(), llvm::createCFGSimplificationPass(), llvm::createCGProfileLegacyPass(), llvm::createConstantMergePass(), llvm::createDeadArgEliminationPass(), llvm::createDivRemPairsPass(), llvm::createEarlyCSEPass(), llvm::createEliminateAvailableExternallyPass(), llvm::createFloat2IntPass(), llvm::createForceFunctionAttrsLegacyPass(), llvm::createFunctionSpecializationPass(), llvm::createGlobalDCEPass(), llvm::createGlobalOptimizerPass(), llvm::createGlobalsAAWrapperPass(), llvm::createHotColdSplittingPass(), llvm::createInferFunctionAttrsLegacyPass(), llvm::createInstrOrderFilePass(), llvm::createInstructionCombiningPass(), llvm::createInstSimplifyLegacyPass(), llvm::createIPSCCPPass(), llvm::createIROutlinerPass(), llvm::createLICMPass(), llvm::createLoopDistributePass(), llvm::createLoopRotatePass(), llvm::createLoopSinkPass(), llvm::createLoopVersioningLICMPass(), llvm::createLowerConstantIntrinsicsPass(), llvm::createLowerMatrixIntrinsicsPass(), llvm::createLowerTypeTestsPass(), llvm::createMergeFunctionsPass(), llvm::createNameAnonGlobalPass(), llvm::createOpenMPOptCGSCCLegacyPass(), llvm::createPartialInliningPass(), llvm::createPostOrderFunctionAttrsLegacyPass(), llvm::createPromoteMemoryToRegisterPass(), llvm::createPruneEHPass(), llvm::createReversePostOrderFunctionAttrsPass(), llvm::createSampleProfileLoaderPass(), llvm::createStripDeadPrototypesPass(), DisableUnrollLoops, llvm::EnableFunctionSpecialization, llvm::EnableHotColdSplit, llvm::EnableIROutliner, llvm::EnableMatrix, llvm::EnableOrderFileInstrumentation, EP_CGSCCOptimizerLate, EP_EnabledOnOptLevel0, EP_ModuleOptimizerEarly, EP_OptimizerLast, EP_Peephole, EP_VectorizerStart, llvm::FlattenedProfileUsed, GlobalExtensionsNotEmpty(), Inliner, LibraryInfo, LicmMssaNoAccForPromotionCap, LicmMssaOptCap, MergeFunctions, llvm::MODULE, MPM, OptLevel, PerformThinLTO, PGOSampleUse, PrepareForLTO, PrepareForThinLTO, llvm::RunPartialInlining, SizeLevel, and llvm::UseLoopVersioningLICM.
|
static |
Removes an extension that was previously added using addGlobalExtension.
This is also intended to be used by plugins, to remove any extension that was previously registered before being unloaded.
ExtensionID | Identifier of the extension to be removed. |
Definition at line 237 of file PassManagerBuilder.cpp.
References assert(), llvm::find_if(), and GlobalExtensions.
Referenced by llvm::RegisterStandardPasses::~RegisterStandardPasses().
bool llvm::PassManagerBuilder::CallGraphProfile |
Definition at line 156 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder(), and populateModulePassManager().
bool llvm::PassManagerBuilder::DisableGVNLoadPRE |
Definition at line 162 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder().
bool llvm::PassManagerBuilder::DisableUnrollLoops |
Definition at line 155 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder(), and populateModulePassManager().
bool llvm::PassManagerBuilder::DivergentTarget |
Definition at line 170 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder().
bool llvm::PassManagerBuilder::EnablePGOCSInstrGen |
Enable profile context sensitive instrumentation pass.
Definition at line 177 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder().
bool llvm::PassManagerBuilder::EnablePGOCSInstrUse |
Enable profile context sensitive profile use pass.
Definition at line 179 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder().
bool llvm::PassManagerBuilder::EnablePGOInstrGen |
Enable profile instrumentation pass.
Definition at line 175 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder().
ModuleSummaryIndex* llvm::PassManagerBuilder::ExportSummary = nullptr |
The module summary index to use for exporting information from the regular LTO phase, for example for the CFI and devirtualization type tests.
Definition at line 148 of file PassManagerBuilder.h.
bool llvm::PassManagerBuilder::ForgetAllSCEVInLoopUnroll |
Definition at line 163 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder().
const ModuleSummaryIndex* llvm::PassManagerBuilder::ImportSummary = nullptr |
The module summary index to use for importing information to the thin LTO backends, for example for the CFI and devirtualization type tests.
Definition at line 153 of file PassManagerBuilder.h.
Pass* llvm::PassManagerBuilder::Inliner |
Inliner - Specifies the inliner to use.
If this is non-null, it is added to the per-module passes.
Definition at line 143 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder(), populateModulePassManager(), and ~PassManagerBuilder().
TargetLibraryInfoImpl* llvm::PassManagerBuilder::LibraryInfo |
LibraryInfo - Specifies information about the runtime library for the optimizer.
If this is non-null, it is added to both the function and per-module pass pipeline.
Definition at line 139 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder(), populateFunctionPassManager(), populateModulePassManager(), and ~PassManagerBuilder().
unsigned llvm::PassManagerBuilder::LicmMssaNoAccForPromotionCap |
Definition at line 172 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder(), and populateModulePassManager().
unsigned llvm::PassManagerBuilder::LicmMssaOptCap |
Definition at line 171 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder(), and populateModulePassManager().
bool llvm::PassManagerBuilder::LoopsInterleaved |
Definition at line 159 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder().
bool llvm::PassManagerBuilder::LoopVectorize |
Definition at line 158 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder().
bool llvm::PassManagerBuilder::MergeFunctions |
Definition at line 166 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder(), and populateModulePassManager().
bool llvm::PassManagerBuilder::NewGVN |
Definition at line 161 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder().
unsigned llvm::PassManagerBuilder::OptLevel |
The Optimization Level - Specify the basic optimization level.
0 = -O0, 1 = -O1, 2 = -O2, 3 = -O3
Definition at line 130 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder(), populateFunctionPassManager(), and populateModulePassManager().
bool llvm::PassManagerBuilder::PerformThinLTO |
Definition at line 169 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder(), and populateModulePassManager().
std::string llvm::PassManagerBuilder::PGOInstrGen |
Profile data file name that the instrumentation will be written to.
Definition at line 181 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder().
std::string llvm::PassManagerBuilder::PGOInstrUse |
Path of the profile data file.
Definition at line 183 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder().
std::string llvm::PassManagerBuilder::PGOSampleUse |
Path of the sample Profile data file.
Definition at line 185 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder(), and populateModulePassManager().
bool llvm::PassManagerBuilder::PrepareForLTO |
Definition at line 167 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder(), and populateModulePassManager().
bool llvm::PassManagerBuilder::PrepareForThinLTO |
Definition at line 168 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder(), and populateModulePassManager().
bool llvm::PassManagerBuilder::RerollLoops |
Definition at line 160 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder().
unsigned llvm::PassManagerBuilder::SizeLevel |
SizeLevel - How much we're optimizing for size.
0 = none, 1 = -Os, 2 = -Oz
Definition at line 134 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder(), and populateModulePassManager().
bool llvm::PassManagerBuilder::SLPVectorize |
Definition at line 157 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder().
bool llvm::PassManagerBuilder::VerifyInput |
Definition at line 164 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder().
bool llvm::PassManagerBuilder::VerifyOutput |
Definition at line 165 of file PassManagerBuilder.h.
Referenced by PassManagerBuilder().