LLVM API Documentation

Public Types | Public Member Functions | Static Public Member Functions | Public Attributes
llvm::PassManagerBuilder Class Reference

#include <PassManagerBuilder.h>

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

List of all members.

Public Types

enum  ExtensionPointTy {
  EP_EarlyAsPossible, EP_ModuleOptimizerEarly, EP_LoopOptimizerEnd, EP_ScalarOptimizerLate,
  EP_OptimizerLast, EP_EnabledOnOptLevel0
}
typedef void(* ExtensionFn )(const PassManagerBuilder &Builder, PassManagerBase &PM)

Public Member Functions

 PassManagerBuilder ()
 ~PassManagerBuilder ()
void addExtension (ExtensionPointTy Ty, ExtensionFn Fn)
void populateFunctionPassManager (FunctionPassManager &FPM)
void populateModulePassManager (PassManagerBase &MPM)
 populateModulePassManager - This sets up the primary pass manager.
void populateLTOPassManager (PassManagerBase &PM, bool Internalize, bool RunInliner, bool DisableGVNLoadPRE=false)

Static Public Member Functions

static void addGlobalExtension (ExtensionPointTy Ty, ExtensionFn Fn)

Public Attributes

unsigned OptLevel
unsigned SizeLevel
TargetLibraryInfoLibraryInfo
PassInliner
bool DisableSimplifyLibCalls
bool DisableUnitAtATime
bool DisableUnrollLoops
bool BBVectorize
bool SLPVectorize
bool LoopVectorize

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 50 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 55 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_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.

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


Constructor & Destructor Documentation

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

Definition at line 65 of file PassManagerBuilder.cpp.

References Inliner, and LibraryInfo.


Member Function Documentation

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

Definition at line 80 of file PassManagerBuilder.cpp.

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

References GlobalExtensions.

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

void PassManagerBuilder::populateFunctionPassManager ( 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 103 of file PassManagerBuilder.cpp.

References llvm::FunctionPassManager::add(), llvm::createCFGSimplificationPass(), llvm::createEarlyCSEPass(), llvm::createLowerExpectIntrinsicPass(), llvm::createScalarReplAggregatesPass(), llvm::createSROAPass(), EP_EarlyAsPossible, LibraryInfo, OptLevel, and UseNewSROA.

Referenced by LLVMPassManagerBuilderPopulateFunctionPassManager().

void PassManagerBuilder::populateLTOPassManager ( PassManagerBase PM,
bool  Internalize,
bool  RunInliner,
bool  DisableGVNLoadPRE = false 
)
void PassManagerBuilder::populateModulePassManager ( PassManagerBase MPM)

populateModulePassManager - This sets up the primary pass manager.

Definition at line 122 of file PassManagerBuilder.cpp.

References llvm::PassManagerBase::add(), BBVectorize, llvm::createAggressiveDCEPass(), llvm::createArgumentPromotionPass(), llvm::createBarrierNoopPass(), llvm::createBBVectorizePass(), llvm::createCFGSimplificationPass(), llvm::createConstantMergePass(), llvm::createCorrelatedValuePropagationPass(), llvm::createDeadArgEliminationPass(), llvm::createDeadStoreEliminationPass(), llvm::createEarlyCSEPass(), llvm::createFunctionAttrsPass(), llvm::createGlobalDCEPass(), llvm::createGlobalOptimizerPass(), llvm::createGVNPass(), llvm::createIndVarSimplifyPass(), llvm::createInstructionCombiningPass(), llvm::createIPSCCPPass(), llvm::createJumpThreadingPass(), llvm::createLICMPass(), llvm::createLoopDeletionPass(), llvm::createLoopIdiomPass(), llvm::createLoopRotatePass(), llvm::createLoopUnrollPass(), llvm::createLoopUnswitchPass(), llvm::createLoopVectorizePass(), llvm::createMemCpyOptPass(), llvm::createPruneEHPass(), llvm::createReassociatePass(), llvm::createScalarReplAggregatesPass(), llvm::createSCCPPass(), llvm::createSimplifyLibCallsPass(), llvm::createSLPVectorizerPass(), llvm::createSROAPass(), llvm::createStripDeadPrototypesPass(), llvm::createTailCallEliminationPass(), DisableSimplifyLibCalls, DisableUnitAtATime, DisableUnrollLoops, EP_EnabledOnOptLevel0, EP_LoopOptimizerEnd, EP_ModuleOptimizerEarly, EP_OptimizerLast, EP_ScalarOptimizerLate, GlobalExtensions, LibraryInfo, LoopVectorize, OptLevel, SizeLevel, SLPVectorize, UseGVNAfterVectorization, and UseNewSROA.

Referenced by LLVMPassManagerBuilderPopulateModulePassManager().


Member Data Documentation

Inliner - Specifies the inliner to use. If this is non-null, it is added to the per-module passes.

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

Referenced by LLVMPassManagerBuilderUseInlinerWithThreshold(), and ~PassManagerBuilder().

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

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

The Optimization Level - Specify the basic optimization level. 0 = -O0, 1 = -O1, 2 = -O2, 3 = -O3

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

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

SizeLevel - How much we're optimizing for size. 0 = none, 1 = -Os, 2 = -Oz

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

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


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