LLVM  4.0.0
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 <PassManagerBuilder.h>

Collaboration diagram for llvm::PassManagerBuilder:
[legend]

Public Types

enum  ExtensionPointTy {
  EP_EarlyAsPossible, EP_ModuleOptimizerEarly, EP_LoopOptimizerEnd, EP_ScalarOptimizerLate,
  EP_OptimizerLast, EP_VectorizerStart, EP_EnabledOnOptLevel0, EP_Peephole,
  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...
 
bool DisableTailCalls
 
bool DisableUnitAtATime
 
bool DisableUnrollLoops
 
bool BBVectorize
 
bool SLPVectorize
 
bool LoopVectorize
 
bool RerollLoops
 
bool LoadCombine
 
bool NewGVN
 
bool DisableGVNLoadPRE
 
bool VerifyInput
 
bool VerifyOutput
 
bool MergeFunctions
 
bool PrepareForLTO
 
bool PrepareForThinLTO
 
bool PerformThinLTO
 
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 58 of file Transforms/IPO/PassManagerBuilder.h.

Member Typedef Documentation

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 64 of file Transforms/IPO/PassManagerBuilder.h.

Member Enumeration Documentation

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_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 65 of file Transforms/IPO/PassManagerBuilder.h.

Constructor & Destructor Documentation

PassManagerBuilder::PassManagerBuilder ( )
PassManagerBuilder::~PassManagerBuilder ( )

Definition at line 177 of file PassManagerBuilder.cpp.

References Inliner, and LibraryInfo.

Member Function Documentation

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

Definition at line 192 of file PassManagerBuilder.cpp.

Referenced by llvm::addCoroutinePassesToExtensionPoints().

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

References GlobalExtensions.

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

References llvm::legacy::FunctionPassManager::add(), llvm::createCFGSimplificationPass(), llvm::createEarlyCSEPass(), llvm::createGVNHoistPass(), llvm::createLowerExpectIntrinsicPass(), llvm::createSROAPass(), EnableGVNHoist, EP_EarlyAsPossible, LibraryInfo, and OptLevel.

Referenced by LLVMPassManagerBuilderPopulateFunctionPassManager().

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

populateModulePassManager - This sets up the primary pass manager.

PGO instrumentation is added during the compile phase for ThinLTO, do not run it a second time

Definition at line 386 of file PassManagerBuilder.cpp.

References llvm::legacy::PassManagerBase::add(), BBVectorize, llvm::createAlignmentFromAssumptionsPass(), llvm::createArgumentPromotionPass(), llvm::createBarrierNoopPass(), llvm::createBBVectorizePass(), llvm::createCFGSimplificationPass(), llvm::createConstantMergePass(), llvm::createCorrelatedValuePropagationPass(), llvm::createDeadArgEliminationPass(), llvm::createEarlyCSEPass(), llvm::createEliminateAvailableExternallyPass(), llvm::createFloat2IntPass(), llvm::createForceFunctionAttrsLegacyPass(), llvm::createGlobalDCEPass(), llvm::createGlobalOptimizerPass(), llvm::createGlobalsAAWrapperPass(), llvm::createGVNPass(), llvm::createInferFunctionAttrsLegacyPass(), llvm::createInstructionSimplifierPass(), llvm::createIPSCCPPass(), llvm::createLICMPass(), llvm::createLoopDistributePass(), llvm::createLoopLoadEliminationPass(), llvm::createLoopRotatePass(), llvm::createLoopSinkPass(), llvm::createLoopUnrollPass(), llvm::createLoopUnswitchPass(), llvm::createLoopVectorizePass(), llvm::createLoopVersioningLICMPass(), llvm::createMergeFunctionsPass(), llvm::createNameAnonGlobalPass(), llvm::createNewGVNPass(), llvm::createPGOIndirectCallPromotionLegacyPass(), llvm::createPostOrderFunctionAttrsLegacyPass(), llvm::createPromoteMemoryToRegisterPass(), llvm::createPruneEHPass(), llvm::createReversePostOrderFunctionAttrsPass(), llvm::createSampleProfileLoaderPass(), llvm::createSLPVectorizerPass(), llvm::createStripDeadPrototypesPass(), DisableGVNLoadPRE, DisableUnitAtATime, DisableUnrollLoops, EnableLoopLoadElim, EnableNonLTOGlobalsModRef, EP_CGSCCOptimizerLate, EP_EnabledOnOptLevel0, EP_ModuleOptimizerEarly, EP_OptimizerLast, EP_Peephole, EP_VectorizerStart, ExtraVectorizerPasses, GlobalExtensions, Inliner, LibraryInfo, LoopVectorize, MergeFunctions, OptLevel, PerformThinLTO, PGOSampleUse, PrepareForLTO, PrepareForThinLTO, RunSLPAfterLoopVectorization, SizeLevel, SLPVectorize, UseGVNAfterVectorization, and UseLoopVersioningLICM.

Referenced by LLVMPassManagerBuilderPopulateModulePassManager(), and populateThinLTOPassManager().

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

Member Data Documentation

bool llvm::PassManagerBuilder::BBVectorize
bool llvm::PassManagerBuilder::DisableGVNLoadPRE
bool llvm::PassManagerBuilder::DisableTailCalls

Definition at line 126 of file Transforms/IPO/PassManagerBuilder.h.

bool llvm::PassManagerBuilder::DisableUnitAtATime
bool llvm::PassManagerBuilder::DisableUnrollLoops
bool llvm::PassManagerBuilder::EnablePGOInstrGen

Enable profile instrumentation pass.

Definition at line 144 of file Transforms/IPO/PassManagerBuilder.h.

Referenced by PassManagerBuilder().

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 124 of file Transforms/IPO/PassManagerBuilder.h.

Referenced by LLVMPassManagerBuilderPopulateLTOPassManager(), LLVMPassManagerBuilderUseInlinerWithThreshold(), 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 120 of file Transforms/IPO/PassManagerBuilder.h.

Referenced by PassManagerBuilder(), populateFunctionPassManager(), populateLTOPassManager(), populateModulePassManager(), and ~PassManagerBuilder().

bool llvm::PassManagerBuilder::LoadCombine

Definition at line 133 of file Transforms/IPO/PassManagerBuilder.h.

Referenced by PassManagerBuilder().

bool llvm::PassManagerBuilder::LoopVectorize
bool llvm::PassManagerBuilder::MergeFunctions
bool llvm::PassManagerBuilder::NewGVN

Definition at line 134 of file Transforms/IPO/PassManagerBuilder.h.

unsigned llvm::PassManagerBuilder::OptLevel

The Optimization Level - Specify the basic optimization level.

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

Definition at line 111 of file Transforms/IPO/PassManagerBuilder.h.

Referenced by LLVMPassManagerBuilderSetOptLevel(), PassManagerBuilder(), populateFunctionPassManager(), populateLTOPassManager(), and populateModulePassManager().

bool llvm::PassManagerBuilder::PerformThinLTO
std::string llvm::PassManagerBuilder::PGOInstrGen

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

Definition at line 146 of file Transforms/IPO/PassManagerBuilder.h.

Referenced by PassManagerBuilder().

std::string llvm::PassManagerBuilder::PGOInstrUse

Path of the profile data file.

Definition at line 148 of file Transforms/IPO/PassManagerBuilder.h.

Referenced by PassManagerBuilder().

std::string llvm::PassManagerBuilder::PGOSampleUse

Path of the sample Profile data file.

Definition at line 150 of file Transforms/IPO/PassManagerBuilder.h.

Referenced by populateModulePassManager().

bool llvm::PassManagerBuilder::PrepareForLTO
bool llvm::PassManagerBuilder::PrepareForThinLTO
bool llvm::PassManagerBuilder::RerollLoops

Definition at line 132 of file Transforms/IPO/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 115 of file Transforms/IPO/PassManagerBuilder.h.

Referenced by LLVMPassManagerBuilderSetSizeLevel(), PassManagerBuilder(), and populateModulePassManager().

bool llvm::PassManagerBuilder::SLPVectorize
bool llvm::PassManagerBuilder::VerifyInput
bool llvm::PassManagerBuilder::VerifyOutput

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