LLVM  4.0.0
Transforms/IPO.h
Go to the documentation of this file.
1 //===- llvm/Transforms/IPO.h - Interprocedural Transformations --*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This header file defines prototypes for accessor functions that expose passes
11 // in the IPO transformations library.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_TRANSFORMS_IPO_H
16 #define LLVM_TRANSFORMS_IPO_H
17 
18 #include <functional>
19 #include <vector>
20 
21 namespace llvm {
22 
23 struct InlineParams;
24 class StringRef;
25 class ModuleSummaryIndex;
26 class ModulePass;
27 class Pass;
28 class Function;
29 class BasicBlock;
30 class GlobalValue;
31 class raw_ostream;
32 
33 //===----------------------------------------------------------------------===//
34 //
35 // These functions removes symbols from functions and modules. If OnlyDebugInfo
36 // is true, only debugging information is removed from the module.
37 //
38 ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
39 
40 //===----------------------------------------------------------------------===//
41 //
42 // These functions strips symbols from functions and modules.
43 // Only debugging information is not stripped.
44 //
45 ModulePass *createStripNonDebugSymbolsPass();
46 
47 /// This function returns a new pass that downgrades the debug info in the
48 /// module to line tables only.
50 
51 //===----------------------------------------------------------------------===//
52 //
53 // These pass removes llvm.dbg.declare intrinsics.
54 ModulePass *createStripDebugDeclarePass();
55 
56 //===----------------------------------------------------------------------===//
57 //
58 // These pass removes unused symbols' debug info.
59 ModulePass *createStripDeadDebugInfoPass();
60 
61 //===----------------------------------------------------------------------===//
62 /// createConstantMergePass - This function returns a new pass that merges
63 /// duplicate global constants together into a single constant that is shared.
64 /// This is useful because some passes (ie TraceValues) insert a lot of string
65 /// constants into the program, regardless of whether or not they duplicate an
66 /// existing string.
67 ///
68 ModulePass *createConstantMergePass();
69 
70 //===----------------------------------------------------------------------===//
71 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
72 /// non-address taken internal globals.
73 ///
74 ModulePass *createGlobalOptimizerPass();
75 
76 //===----------------------------------------------------------------------===//
77 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
78 /// internal globals (functions or global variables)
79 ///
80 ModulePass *createGlobalDCEPass();
81 
82 //===----------------------------------------------------------------------===//
83 /// This transform is designed to eliminate available external globals
84 /// (functions or global variables)
85 ///
87 
88 //===----------------------------------------------------------------------===//
89 /// createGVExtractionPass - If deleteFn is true, this pass deletes
90 /// the specified global values. Otherwise, it deletes as much of the module as
91 /// possible, except for the global values specified.
92 ///
93 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
94  deleteFn = false);
95 
96 //===----------------------------------------------------------------------===//
97 /// This pass performs iterative function importing from other modules.
99 
100 //===----------------------------------------------------------------------===//
101 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
102 /// to inline direct function calls to small functions.
103 ///
104 /// The Threshold can be passed directly, or asked to be computed from the
105 /// given optimization and size optimization arguments.
106 ///
107 /// The -inline-threshold command line option takes precedence over the
108 /// threshold given here.
111 Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel);
112 Pass *createFunctionInliningPass(InlineParams &Params);
113 
114 //===----------------------------------------------------------------------===//
115 /// createPruneEHPass - Return a new pass object which transforms invoke
116 /// instructions into calls, if the callee can _not_ unwind the stack.
117 ///
119 
120 //===----------------------------------------------------------------------===//
121 /// createInternalizePass - This pass loops over all of the functions in the
122 /// input module, internalizing all globals (functions and variables) it can.
123 ////
124 /// Before internalizing a symbol, the callback \p MustPreserveGV is invoked and
125 /// gives to the client the ability to prevent internalizing specific symbols.
126 ///
127 /// The symbol in DSOList are internalized if it is safe to drop them from
128 /// the symbol table.
129 ///
130 /// Note that commandline options that are used with the above function are not
131 /// used now!
132 ModulePass *
133 createInternalizePass(std::function<bool(const GlobalValue &)> MustPreserveGV);
134 
135 /// createInternalizePass - Same as above, but with an empty exportList.
136 ModulePass *createInternalizePass();
137 
138 //===----------------------------------------------------------------------===//
139 /// createDeadArgEliminationPass - This pass removes arguments from functions
140 /// which are not used by the body of the function.
141 ///
142 ModulePass *createDeadArgEliminationPass();
143 
144 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
145 /// functions as well. This is definitely not safe, and should only be used by
146 /// bugpoint.
147 ModulePass *createDeadArgHackingPass();
148 
149 //===----------------------------------------------------------------------===//
150 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
151 /// be passed by value if the number of elements passed is smaller or
152 /// equal to maxElements (maxElements == 0 means always promote).
153 ///
154 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
155 
156 //===----------------------------------------------------------------------===//
157 /// createIPConstantPropagationPass - This pass propagates constants from call
158 /// sites into the bodies of functions.
159 ///
160 ModulePass *createIPConstantPropagationPass();
161 
162 //===----------------------------------------------------------------------===//
163 /// createIPSCCPPass - This pass propagates constants from call sites into the
164 /// bodies of functions, and keeps track of whether basic blocks are executable
165 /// in the process.
166 ///
167 ModulePass *createIPSCCPPass();
168 
169 //===----------------------------------------------------------------------===//
170 //
171 /// createLoopExtractorPass - This pass extracts all natural loops from the
172 /// program into a function if it can.
173 ///
175 
176 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
177 /// program into a function if it can. This is used by bugpoint.
178 ///
180 
181 /// createBlockExtractorPass - This pass extracts all blocks (except those
182 /// specified in the argument list) from the functions in the module.
183 ///
184 ModulePass *createBlockExtractorPass();
185 
186 /// createStripDeadPrototypesPass - This pass removes any function declarations
187 /// (prototypes) that are not used.
188 ModulePass *createStripDeadPrototypesPass();
189 
190 //===----------------------------------------------------------------------===//
191 /// createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call
192 /// graph in RPO to deduce and propagate function attributes. Currently it
193 /// only handles synthesizing norecurse attributes.
194 ///
196 
197 //===----------------------------------------------------------------------===//
198 /// createMergeFunctionsPass - This pass discovers identical functions and
199 /// collapses them.
200 ///
201 ModulePass *createMergeFunctionsPass();
202 
203 //===----------------------------------------------------------------------===//
204 /// createPartialInliningPass - This pass inlines parts of functions.
205 ///
206 ModulePass *createPartialInliningPass();
207 
208 //===----------------------------------------------------------------------===//
209 // createMetaRenamerPass - Rename everything with metasyntatic names.
210 //
211 ModulePass *createMetaRenamerPass();
212 
213 //===----------------------------------------------------------------------===//
214 /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
215 /// manager.
216 ModulePass *createBarrierNoopPass();
217 
218 /// What to do with the summary when running the LowerTypeTests pass.
220  None, ///< Do nothing.
221  Import, ///< Import typeid resolutions from summary and globals.
222  Export, ///< Export typeid resolutions to summary and globals.
223 };
224 
225 /// \brief This pass lowers type metadata and the llvm.type.test intrinsic to
226 /// bitsets.
227 /// \param Action What to do with the summary passed as Index.
228 /// \param Index The summary to use for importing or exporting, this can be null
229 /// when Action is None.
231  ModuleSummaryIndex *Index);
232 
233 /// \brief This pass export CFI checks for use by external modules.
234 ModulePass *createCrossDSOCFIPass();
235 
236 /// \brief This pass implements whole-program devirtualization using type
237 /// metadata.
238 ModulePass *createWholeProgramDevirtPass();
239 
240 /// This pass splits globals into pieces for the benefit of whole-program
241 /// devirtualization and control-flow integrity.
242 ModulePass *createGlobalSplitPass();
243 
244 //===----------------------------------------------------------------------===//
245 // SampleProfilePass - Loads sample profile data from disk and generates
246 // IR metadata to reflect the profile.
247 ModulePass *createSampleProfileLoaderPass();
248 ModulePass *createSampleProfileLoaderPass(StringRef Name);
249 
250 /// Write ThinLTO-ready bitcode to Str.
251 ModulePass *createWriteThinLTOBitcodePass(raw_ostream &Str);
252 
253 } // End llvm namespace
254 
255 #endif
ModulePass * createIPConstantPropagationPass()
createIPConstantPropagationPass - This pass propagates constants from call sites into the bodies of f...
ModulePass * createStripDeadPrototypesPass()
createStripDeadPrototypesPass - This pass removes any function declarations (prototypes) that are not...
Various leaf nodes.
Definition: ISDOpcodes.h:60
aarch64 AArch64 CCMP Pass
ModulePass * createMergeFunctionsPass()
createMergeFunctionsPass - This pass discovers identical functions and collapses them.
ModulePass * createIPSCCPPass()
createIPSCCPPass - This pass propagates constants from call sites into the bodies of functions...
Definition: SCCP.cpp:1955
ModulePass * createStripNonLineTableDebugInfoPass()
This function returns a new pass that downgrades the debug info in the module to line tables only...
Pass * createSingleLoopExtractorPass()
createSingleLoopExtractorPass - This pass extracts one natural loop from the program into a function ...
ModulePass * createEliminateAvailableExternallyPass()
This transform is designed to eliminate available external globals (functions or global variables) ...
ModulePass * createStripNonDebugSymbolsPass()
ModulePass * createBlockExtractorPass()
createBlockExtractorPass - This pass extracts all blocks (except those specified in the argument list...
ModulePass * createStripDeadDebugInfoPass()
ModulePass * createPartialInliningPass()
createPartialInliningPass - This pass inlines parts of functions.
ModulePass * createDeadArgHackingPass()
DeadArgHacking pass - Same as DAE, but delete arguments of external functions as well.
ModulePass * createCrossDSOCFIPass()
This pass export CFI checks for use by external modules.
Pass * createArgumentPromotionPass(unsigned maxElements=3)
createArgumentPromotionPass - This pass promotes "by reference" arguments to be passed by value if th...
ModulePass * createWholeProgramDevirtPass()
This pass implements whole-program devirtualization using type metadata.
ModulePass * createSampleProfileLoaderPass()
ModulePass * createGlobalDCEPass()
createGlobalDCEPass - This transform is designed to eliminate unreachable internal globals (functions...
Pass * createFunctionImportPass()
This pass performs iterative function importing from other modules.
LowerTypeTestsSummaryAction
What to do with the summary when running the LowerTypeTests pass.
ModulePass * createDeadArgEliminationPass()
createDeadArgEliminationPass - This pass removes arguments from functions which are not used by the b...
ModulePass * createBarrierNoopPass()
createBarrierNoopPass - This pass is purely a module pass barrier in a pass manager.
ModulePass * createConstantMergePass()
createConstantMergePass - This function returns a new pass that merges duplicate global constants tog...
ModulePass * createGlobalOptimizerPass()
createGlobalOptimizerPass - This function returns a new pass that optimizes non-address taken interna...
Definition: GlobalOpt.cpp:2599
Pass * createReversePostOrderFunctionAttrsPass()
createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call graph in RPO to deduce and...
ModulePass * createStripDebugDeclarePass()
ModulePass * createGlobalSplitPass()
This pass splits globals into pieces for the benefit of whole-program devirtualization and control-fl...
Import typeid resolutions from summary and globals.
ModulePass * createInternalizePass(std::function< bool(const GlobalValue &)> MustPreserveGV)
createInternalizePass - This pass loops over all of the functions in the input module, internalizing all globals (functions and variables) it can.
Pass * createLoopExtractorPass()
createLoopExtractorPass - This pass extracts all natural loops from the program into a function if it...
ModulePass * createLowerTypeTestsPass(LowerTypeTestsSummaryAction Action, ModuleSummaryIndex *Index)
This pass lowers type metadata and the llvm.type.test intrinsic to bitsets.
ModulePass * createWriteThinLTOBitcodePass(raw_ostream &Str)
Write ThinLTO-ready bitcode to Str.
static int const Threshold
TODO: Write a new FunctionPass AliasAnalysis so that it can keep a cache.
Pass * createFunctionInliningPass()
createFunctionInliningPass - Return a new pass object that uses a heuristic to inline direct function...
Pass * createPruneEHPass()
createPruneEHPass - Return a new pass object which transforms invoke instructions into calls...
Definition: PruneEH.cpp:62
ModulePass * createStripSymbolsPass(bool OnlyDebugInfo=false)
ModulePass * createGVExtractionPass(std::vector< GlobalValue * > &GVs, bool deleteFn=false)
createGVExtractionPass - If deleteFn is true, this pass deletes the specified global values...
Definition: ExtractGV.cpp:160
print Print MemDeps of function
Export typeid resolutions to summary and globals.
ModulePass * createMetaRenamerPass()