LLVM  8.0.1
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
llvm::PassManagerBuilder Class Reference

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"

Collaboration diagram for llvm::PassManagerBuilder:
Collaboration graph
[legend]

Public Types

enum  ExtensionPointTy {
  EP_EarlyAsPossible, EP_ModuleOptimizerEarly, EP_LoopOptimizerEnd, EP_ScalarOptimizerLate,
  EP_OptimizerLast, EP_VectorizerStart, EP_EnabledOnOptLevel0, EP_Peephole,
  EP_LateLoopOptimizations, EP_CGSCCOptimizerLate
}
 
typedef std::function< void(const PassManagerBuilder &Builder, legacy::PassManagerBase &PM)> ExtensionFn
 Extensions are passed the builder itself (so they can see how it is configured) as well as the pass manager to add stuff to. More...
 

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...
 
void populateLTOPassManager (legacy::PassManagerBase &PM)
 
void populateThinLTOPassManager (legacy::PassManagerBase &PM)
 

Static Public Member Functions

static void addGlobalExtension (ExtensionPointTy Ty, ExtensionFn Fn)
 Adds an extension that will be used by all PassManagerBuilder instances. 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...
 
TargetLibraryInfoImplLibraryInfo
 LibraryInfo - Specifies information about the runtime library for the optimizer. More...
 
PassInliner
 Inliner - Specifies the inliner to use. More...
 
ModuleSummaryIndexExportSummary = 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 ModuleSummaryIndexImportSummary = 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 DisableTailCalls
 
bool DisableUnitAtATime
 
bool DisableUnrollLoops
 
bool SLPVectorize
 
bool LoopVectorize
 
bool RerollLoops
 
bool NewGVN
 
bool DisableGVNLoadPRE
 
bool VerifyInput
 
bool VerifyOutput
 
bool MergeFunctions
 
bool PrepareForLTO
 
bool PrepareForThinLTO
 
bool PerformThinLTO
 
bool DivergentTarget
 
bool EnablePGOInstrGen
 Enable profile instrumentation 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...
 

Detailed Description

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 59 of file PassManagerBuilder.h.

Member Typedef Documentation

◆ ExtensionFn

Extensions are passed the builder itself (so they can see how it is configured) as well as the pass manager to add stuff to.

Definition at line 65 of file PassManagerBuilder.h.

Member Enumeration Documentation

◆ ExtensionPointTy

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.

Definition at line 66 of file PassManagerBuilder.h.

Constructor & Destructor Documentation

◆ PassManagerBuilder()

PassManagerBuilder::PassManagerBuilder ( )

◆ ~PassManagerBuilder()

PassManagerBuilder::~PassManagerBuilder ( )

Definition at line 186 of file PassManagerBuilder.cpp.

References Inliner.

Member Function Documentation

◆ addExtension()

void PassManagerBuilder::addExtension ( ExtensionPointTy  Ty,
ExtensionFn  Fn 
)

◆ addGlobalExtension()

void PassManagerBuilder::addGlobalExtension ( PassManagerBuilder::ExtensionPointTy  Ty,
PassManagerBuilder::ExtensionFn  Fn 
)
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 202 of file PassManagerBuilder.cpp.

Referenced by llvm::RegisterStandardPasses::RegisterStandardPasses().

◆ populateFunctionPassManager()

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 255 of file PassManagerBuilder.cpp.

References llvm::legacy::PassManagerBase::add(), llvm::legacy::FunctionPassManager::add(), llvm::createAggressiveDCEPass(), llvm::createAggressiveInstCombinerPass(), llvm::createBitTrackingDCEPass(), llvm::createCFGSimplificationPass(), llvm::createControlHeightReductionLegacyPass(), llvm::createCorrelatedValuePropagationPass(), llvm::createDeadStoreEliminationPass(), llvm::createEarlyCSEPass(), llvm::createEntryExitInstrumenterPass(), llvm::createFunctionInliningPass(), llvm::createGVNHoistPass(), llvm::createGVNPass(), llvm::createGVNSinkPass(), llvm::createIndVarSimplifyPass(), llvm::createInstrProfilingLegacyPass(), llvm::createInstructionCombiningPass(), llvm::createJumpThreadingPass(), llvm::createLibCallsShrinkWrapPass(), llvm::createLICMPass(), llvm::createLoopDeletionPass(), llvm::createLoopIdiomPass(), llvm::createLoopInstSimplifyPass(), llvm::createLoopInterchangePass(), llvm::createLoopRerollPass(), llvm::createLoopRotatePass(), llvm::createLoopSimplifyCFGPass(), llvm::createLoopUnswitchPass(), llvm::createLowerExpectIntrinsicPass(), llvm::createMemCpyOptPass(), llvm::createMergedLoadStoreMotionPass(), llvm::createNewGVNPass(), llvm::createPGOIndirectCallPromotionLegacyPass(), llvm::createPGOInstrumentationGenLegacyPass(), llvm::createPGOInstrumentationUseLegacyPass(), llvm::createPGOMemOPSizeOptLegacyPass(), llvm::createReassociatePass(), llvm::createSCCPPass(), llvm::createSimpleLoopUnrollPass(), llvm::createSimpleLoopUnswitchLegacyPass(), llvm::createSLPVectorizerPass(), llvm::createSpeculativeExecutionIfHasBranchDivergencePass(), llvm::createSROAPass(), llvm::createTailCallEliminationPass(), llvm::InlineParams::DefaultThreshold, llvm::InstrProfOptions::DoCounterPromotion, llvm::InlineParams::HintThreshold, llvm::InstrProfOptions::InstrProfileOutput, PreInlineThreshold, and RunSLPAfterLoopVectorization.

Referenced by LLVMPassManagerBuilderPopulateFunctionPassManager().

◆ populateLTOPassManager()

void PassManagerBuilder::populateLTOPassManager ( legacy::PassManagerBase PM)

◆ populateModulePassManager()

void PassManagerBuilder::populateModulePassManager ( legacy::PassManagerBase MPM)

populateModulePassManager - This sets up the primary pass manager.

Definition at line 426 of file PassManagerBuilder.cpp.

References llvm::legacy::PassManagerBase::add(), llvm::createAggressiveInstCombinerPass(), llvm::createAlignmentFromAssumptionsPass(), llvm::createArgumentPromotionPass(), llvm::createBarrierNoopPass(), llvm::createBitTrackingDCEPass(), llvm::createCalledValuePropagationPass(), llvm::createCallSiteSplittingPass(), llvm::createCanonicalizeAliasesPass(), llvm::createCFGSimplificationPass(), llvm::createConstantMergePass(), llvm::createCorrelatedValuePropagationPass(), llvm::createDeadArgEliminationPass(), llvm::createDeadStoreEliminationPass(), llvm::createDivRemPairsPass(), llvm::createEarlyCSEPass(), llvm::createEliminateAvailableExternallyPass(), llvm::createFloat2IntPass(), llvm::createForceFunctionAttrsLegacyPass(), llvm::createGlobalDCEPass(), llvm::createGlobalOptimizerPass(), llvm::createGlobalsAAWrapperPass(), llvm::createGlobalSplitPass(), llvm::createGVNPass(), llvm::createHotColdSplittingPass(), llvm::createIndVarSimplifyPass(), llvm::createInferFunctionAttrsLegacyPass(), llvm::createInstSimplifyLegacyPass(), llvm::createIPSCCPPass(), llvm::createJumpThreadingPass(), llvm::createLICMPass(), llvm::createLoopDeletionPass(), llvm::createLoopDistributePass(), llvm::createLoopInterchangePass(), llvm::createLoopLoadEliminationPass(), llvm::createLoopRotatePass(), llvm::createLoopSinkPass(), llvm::createLoopUnrollAndJamPass(), llvm::createLoopUnrollPass(), llvm::createLoopUnswitchPass(), llvm::createLoopVectorizePass(), llvm::createLoopVersioningLICMPass(), llvm::createMemCpyOptPass(), llvm::createMergedLoadStoreMotionPass(), llvm::createMergeFunctionsPass(), llvm::createNameAnonGlobalPass(), llvm::createNewGVNPass(), llvm::createPartialInliningPass(), llvm::createPGOIndirectCallPromotionLegacyPass(), llvm::createPostOrderFunctionAttrsLegacyPass(), llvm::createPromoteMemoryToRegisterPass(), llvm::createPruneEHPass(), llvm::createReversePostOrderFunctionAttrsPass(), llvm::createSampleProfileLoaderPass(), llvm::createSCCPPass(), llvm::createSimpleLoopUnrollPass(), llvm::createSLPVectorizerPass(), llvm::createSROAPass(), llvm::createStripDeadPrototypesPass(), llvm::createWarnMissedTransformationsPass(), llvm::createWholeProgramDevirtPass(), Extensions, ExtraVectorizerPasses, GlobalExtensionsNotEmpty(), Inliner, RunPartialInlining, and RunSLPAfterLoopVectorization.

Referenced by LLVMPassManagerBuilderPopulateModulePassManager().

◆ populateThinLTOPassManager()

void PassManagerBuilder::populateThinLTOPassManager ( legacy::PassManagerBase PM)

Member Data Documentation

◆ DisableGVNLoadPRE

bool llvm::PassManagerBuilder::DisableGVNLoadPRE

Definition at line 152 of file PassManagerBuilder.h.

Referenced by llvm::LTOCodeGenerator::optimize().

◆ DisableTailCalls

bool llvm::PassManagerBuilder::DisableTailCalls

Definition at line 145 of file PassManagerBuilder.h.

◆ DisableUnitAtATime

bool llvm::PassManagerBuilder::DisableUnitAtATime

Definition at line 146 of file PassManagerBuilder.h.

◆ DisableUnrollLoops

bool llvm::PassManagerBuilder::DisableUnrollLoops

Definition at line 147 of file PassManagerBuilder.h.

Referenced by LLVMPassManagerBuilderSetDisableUnrollLoops().

◆ DivergentTarget

bool llvm::PassManagerBuilder::DivergentTarget

Definition at line 159 of file PassManagerBuilder.h.

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

◆ EnablePGOInstrGen

bool llvm::PassManagerBuilder::EnablePGOInstrGen

Enable profile instrumentation pass.

Definition at line 162 of file PassManagerBuilder.h.

◆ ExportSummary

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 138 of file PassManagerBuilder.h.

◆ ImportSummary

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 143 of file PassManagerBuilder.h.

◆ Inliner

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 133 of file PassManagerBuilder.h.

Referenced by llvm::AMDGPUTargetMachine::adjustPassManager(), LLVMPassManagerBuilderPopulateLTOPassManager(), and LLVMPassManagerBuilderUseInlinerWithThreshold().

◆ LibraryInfo

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 129 of file PassManagerBuilder.h.

◆ LoopVectorize

bool llvm::PassManagerBuilder::LoopVectorize

Definition at line 149 of file PassManagerBuilder.h.

◆ MergeFunctions

bool llvm::PassManagerBuilder::MergeFunctions

Definition at line 155 of file PassManagerBuilder.h.

◆ NewGVN

bool llvm::PassManagerBuilder::NewGVN

Definition at line 151 of file PassManagerBuilder.h.

◆ OptLevel

unsigned llvm::PassManagerBuilder::OptLevel

The Optimization Level - Specify the basic optimization level.

0 = -O0, 1 = -O1, 2 = -O2, 3 = -O3

Definition at line 120 of file PassManagerBuilder.h.

Referenced by LLVMPassManagerBuilderSetOptLevel().

◆ PerformThinLTO

bool llvm::PassManagerBuilder::PerformThinLTO

Definition at line 158 of file PassManagerBuilder.h.

◆ PGOInstrGen

std::string llvm::PassManagerBuilder::PGOInstrGen

Profile data file name that the instrumentation will be written to.

Definition at line 164 of file PassManagerBuilder.h.

◆ PGOInstrUse

std::string llvm::PassManagerBuilder::PGOInstrUse

Path of the profile data file.

Definition at line 166 of file PassManagerBuilder.h.

◆ PGOSampleUse

std::string llvm::PassManagerBuilder::PGOSampleUse

Path of the sample Profile data file.

Definition at line 168 of file PassManagerBuilder.h.

◆ PrepareForLTO

bool llvm::PassManagerBuilder::PrepareForLTO

Definition at line 156 of file PassManagerBuilder.h.

◆ PrepareForThinLTO

bool llvm::PassManagerBuilder::PrepareForThinLTO

Definition at line 157 of file PassManagerBuilder.h.

◆ RerollLoops

bool llvm::PassManagerBuilder::RerollLoops

Definition at line 150 of file PassManagerBuilder.h.

◆ SizeLevel

unsigned llvm::PassManagerBuilder::SizeLevel

SizeLevel - How much we're optimizing for size.

0 = none, 1 = -Os, 2 = -Oz

Definition at line 124 of file PassManagerBuilder.h.

Referenced by LLVMPassManagerBuilderSetSizeLevel().

◆ SLPVectorize

bool llvm::PassManagerBuilder::SLPVectorize

Definition at line 148 of file PassManagerBuilder.h.

◆ VerifyInput

bool llvm::PassManagerBuilder::VerifyInput

Definition at line 153 of file PassManagerBuilder.h.

◆ VerifyOutput

bool llvm::PassManagerBuilder::VerifyOutput

Definition at line 154 of file PassManagerBuilder.h.


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