LLVM  17.0.0git
PassManagerBuilder.h
Go to the documentation of this file.
1 // llvm/Transforms/IPO/PassManagerBuilder.h - Build Standard Pass -*- C++ -*-=//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the PassManagerBuilder class, which is used to set up a
10 // "standard" optimization sequence suitable for languages like C and C++.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_TRANSFORMS_IPO_PASSMANAGERBUILDER_H
15 #define LLVM_TRANSFORMS_IPO_PASSMANAGERBUILDER_H
16 
18 #include <functional>
19 #include <string>
20 #include <vector>
21 
22 namespace llvm {
23 class ModuleSummaryIndex;
24 class Pass;
25 class TargetLibraryInfoImpl;
26 
27 // The old pass manager infrastructure is hidden in a legacy namespace now.
28 namespace legacy {
30 class PassManagerBase;
31 }
32 
33 /// PassManagerBuilder - This class is used to set up a standard optimization
34 /// sequence for languages like C and C++, allowing some APIs to customize the
35 /// pass sequence in various ways. A simple example of using it would be:
36 ///
37 /// PassManagerBuilder Builder;
38 /// Builder.OptLevel = 2;
39 /// Builder.populateFunctionPassManager(FPM);
40 /// Builder.populateModulePassManager(MPM);
41 ///
42 /// In addition to setting up the basic passes, PassManagerBuilder allows
43 /// frontends to vend a plugin API, where plugins are allowed to add extensions
44 /// to the default pass manager. They do this by specifying where in the pass
45 /// pipeline they want to be added, along with a callback function that adds
46 /// the pass(es). For example, a plugin that wanted to add a loop optimization
47 /// could do something like this:
48 ///
49 /// static void addMyLoopPass(const PMBuilder &Builder, PassManagerBase &PM) {
50 /// if (Builder.getOptLevel() > 2 && Builder.getOptSizeLevel() == 0)
51 /// PM.add(createMyAwesomePass());
52 /// }
53 /// ...
54 /// Builder.addExtension(PassManagerBuilder::EP_LoopOptimizerEnd,
55 /// addMyLoopPass);
56 /// ...
58 public:
59  /// Extensions are passed to the builder itself (so they can see how it is
60  /// configured) as well as the pass manager to add stuff to.
61  typedef std::function<void(const PassManagerBuilder &Builder,
64  typedef int GlobalExtensionID;
65 
66  /// The Optimization Level - Specify the basic optimization level.
67  /// 0 = -O0, 1 = -O1, 2 = -O2, 3 = -O3
68  unsigned OptLevel;
69 
70  /// SizeLevel - How much we're optimizing for size.
71  /// 0 = none, 1 = -Os, 2 = -Oz
72  unsigned SizeLevel;
73 
74  /// LibraryInfo - Specifies information about the runtime library for the
75  /// optimizer. If this is non-null, it is added to both the function and
76  /// per-module pass pipeline.
78 
79  /// Inliner - Specifies the inliner to use. If this is non-null, it is
80  /// added to the per-module passes.
82 
83  /// The module summary index to use for exporting information from the
84  /// regular LTO phase, for example for the CFI and devirtualization type
85  /// tests.
87 
88  /// The module summary index to use for importing information to the
89  /// thin LTO backends, for example for the CFI and devirtualization type
90  /// tests.
92 
104  unsigned LicmMssaOptCap;
106 
107 public:
110 
111 private:
112  void addInitialAliasAnalysisPasses(legacy::PassManagerBase &PM) const;
113  void addFunctionSimplificationPasses(legacy::PassManagerBase &MPM);
114  void addVectorPasses(legacy::PassManagerBase &PM, bool IsFullLTO);
115 
116 public:
117  /// populateFunctionPassManager - This fills in the function pass manager,
118  /// which is expected to be run on each function immediately as it is
119  /// generated. The idea is to reduce the size of the IR in memory.
121 
122  /// populateModulePassManager - This sets up the primary pass manager.
124 };
125 
127  return reinterpret_cast<PassManagerBuilder*>(P);
128 }
129 
131  return reinterpret_cast<LLVMPassManagerBuilderRef>(P);
132 }
133 
134 } // end namespace llvm
135 #endif
llvm::PassManagerBuilder::LicmMssaOptCap
unsigned LicmMssaOptCap
Definition: PassManagerBuilder.h:104
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Pass
print lazy value Lazy Value Info Printer Pass
Definition: LazyValueInfo.cpp:2066
llvm::PassManagerBuilder::PassManagerBuilder
PassManagerBuilder()
Definition: PassManagerBuilder.cpp:44
llvm::PassManagerBuilder::VerifyOutput
bool VerifyOutput
Definition: PassManagerBuilder.h:101
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::PassManagerBuilder::LoopVectorize
bool LoopVectorize
Definition: PassManagerBuilder.h:96
llvm::PassManagerBuilder::DisableGVNLoadPRE
bool DisableGVNLoadPRE
Definition: PassManagerBuilder.h:98
llvm::PassManagerBuilder::ImportSummary
const ModuleSummaryIndex * ImportSummary
The module summary index to use for importing information to the thin LTO backends,...
Definition: PassManagerBuilder.h:91
llvm::PassManagerBuilder::ForgetAllSCEVInLoopUnroll
bool ForgetAllSCEVInLoopUnroll
Definition: PassManagerBuilder.h:99
llvm::TargetLibraryInfoImpl
Implementation of the target library information.
Definition: TargetLibraryInfo.h:50
llvm::PassManagerBuilder::ExportSummary
ModuleSummaryIndex * ExportSummary
The module summary index to use for exporting information from the regular LTO phase,...
Definition: PassManagerBuilder.h:86
llvm::PassManagerBuilder::LibraryInfo
TargetLibraryInfoImpl * LibraryInfo
LibraryInfo - Specifies information about the runtime library for the optimizer.
Definition: PassManagerBuilder.h:77
llvm::FunctionPassManager
PassManager< Function > FunctionPassManager
Convenience typedef for a pass manager over functions.
Definition: PassManager.h:587
llvm::unwrap
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:285
llvm::PassManagerBuilder::Inliner
Pass * Inliner
Inliner - Specifies the inliner to use.
Definition: PassManagerBuilder.h:81
llvm::PassManagerBuilder::MergeFunctions
bool MergeFunctions
Definition: PassManagerBuilder.h:102
llvm::PassManagerBuilder::LicmMssaNoAccForPromotionCap
unsigned LicmMssaNoAccForPromotionCap
Definition: PassManagerBuilder.h:105
llvm::PassManagerBuilder::LoopsInterleaved
bool LoopsInterleaved
Definition: PassManagerBuilder.h:97
llvm::PassManagerBuilder
PassManagerBuilder - This class is used to set up a standard optimization sequence for languages like...
Definition: PassManagerBuilder.h:57
llvm::PassManagerBuilder::~PassManagerBuilder
~PassManagerBuilder()
Definition: PassManagerBuilder.cpp:64
llvm::PassManagerBuilder::ExtensionFn
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 pas...
Definition: PassManagerBuilder.h:63
LLVMPassManagerBuilderRef
struct LLVMOpaquePassManagerBuilder * LLVMPassManagerBuilderRef
Definition: PassManagerBuilder.h:20
llvm::PassManagerBuilder::OptLevel
unsigned OptLevel
The Optimization Level - Specify the basic optimization level.
Definition: PassManagerBuilder.h:68
llvm::PassManagerBuilder::GlobalExtensionID
int GlobalExtensionID
Definition: PassManagerBuilder.h:64
llvm::PassManagerBuilder::VerifyInput
bool VerifyInput
Definition: PassManagerBuilder.h:100
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:82
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:651
llvm::wrap
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:280
llvm::PassManagerBuilder::CallGraphProfile
bool CallGraphProfile
Definition: PassManagerBuilder.h:94
llvm::PassManagerBuilder::SLPVectorize
bool SLPVectorize
Definition: PassManagerBuilder.h:95
llvm::PassManagerBuilder::populateModulePassManager
void populateModulePassManager(legacy::PassManagerBase &MPM)
populateModulePassManager - This sets up the primary pass manager.
Definition: PassManagerBuilder.cpp:290
PassManagerBuilder.h
llvm::PassManagerBuilder::SizeLevel
unsigned SizeLevel
SizeLevel - How much we're optimizing for size.
Definition: PassManagerBuilder.h:72
llvm::PassManagerBuilder::populateFunctionPassManager
void populateFunctionPassManager(legacy::FunctionPassManager &FPM)
populateFunctionPassManager - This fills in the function pass manager, which is expected to be run on...
Definition: PassManagerBuilder.cpp:78
llvm::Pass
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:91
llvm::PassManagerBuilder::DisableUnrollLoops
bool DisableUnrollLoops
Definition: PassManagerBuilder.h:93
llvm::ModuleSummaryIndex
Class to hold module path string table and global value map, and encapsulate methods for operating on...
Definition: ModuleSummaryIndex.h:1199
llvm::legacy::FunctionPassManager
FunctionPassManager manages FunctionPasses.
Definition: LegacyPassManager.h:71
llvm::legacy::PassManagerBase
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
Definition: LegacyPassManager.h:39
llvm::PassManagerBuilder::DivergentTarget
bool DivergentTarget
Definition: PassManagerBuilder.h:103
MPM
ModulePassManager MPM
Definition: PassBuilderBindings.cpp:70