LLVM  6.0.0svn
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 // This pass removes llvm.dbg.declare intrinsics.
54 ModulePass *createStripDebugDeclarePass();
55 
56 //===----------------------------------------------------------------------===//
57 //
58 // This 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  bool DisableInlineHotCallSite);
113 Pass *createFunctionInliningPass(InlineParams &Params);
114 
115 //===----------------------------------------------------------------------===//
116 /// createPruneEHPass - Return a new pass object which transforms invoke
117 /// instructions into calls, if the callee can _not_ unwind the stack.
118 ///
120 
121 //===----------------------------------------------------------------------===//
122 /// createInternalizePass - This pass loops over all of the functions in the
123 /// input module, internalizing all globals (functions and variables) it can.
124 ////
125 /// Before internalizing a symbol, the callback \p MustPreserveGV is invoked and
126 /// gives to the client the ability to prevent internalizing specific symbols.
127 ///
128 /// The symbol in DSOList are internalized if it is safe to drop them from
129 /// the symbol table.
130 ///
131 /// Note that commandline options that are used with the above function are not
132 /// used now!
133 ModulePass *
134 createInternalizePass(std::function<bool(const GlobalValue &)> MustPreserveGV);
135 
136 /// createInternalizePass - Same as above, but with an empty exportList.
137 ModulePass *createInternalizePass();
138 
139 //===----------------------------------------------------------------------===//
140 /// createDeadArgEliminationPass - This pass removes arguments from functions
141 /// which are not used by the body of the function.
142 ///
143 ModulePass *createDeadArgEliminationPass();
144 
145 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
146 /// functions as well. This is definitely not safe, and should only be used by
147 /// bugpoint.
148 ModulePass *createDeadArgHackingPass();
149 
150 //===----------------------------------------------------------------------===//
151 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
152 /// be passed by value if the number of elements passed is smaller or
153 /// equal to maxElements (maxElements == 0 means always promote).
154 ///
155 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
156 
157 //===----------------------------------------------------------------------===//
158 /// createIPConstantPropagationPass - This pass propagates constants from call
159 /// sites into the bodies of functions.
160 ///
161 ModulePass *createIPConstantPropagationPass();
162 
163 //===----------------------------------------------------------------------===//
164 /// createIPSCCPPass - This pass propagates constants from call sites into the
165 /// bodies of functions, and keeps track of whether basic blocks are executable
166 /// in the process.
167 ///
168 ModulePass *createIPSCCPPass();
169 
170 //===----------------------------------------------------------------------===//
171 //
172 /// createLoopExtractorPass - This pass extracts all natural loops from the
173 /// program into a function if it can.
174 ///
176 
177 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
178 /// program into a function if it can. This is used by bugpoint.
179 ///
181 
182 /// createBlockExtractorPass - This pass extracts all blocks (except those
183 /// specified in the argument list) from the functions in the module.
184 ///
185 ModulePass *createBlockExtractorPass();
186 
187 /// createStripDeadPrototypesPass - This pass removes any function declarations
188 /// (prototypes) that are not used.
189 ModulePass *createStripDeadPrototypesPass();
190 
191 //===----------------------------------------------------------------------===//
192 /// createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call
193 /// graph in RPO to deduce and propagate function attributes. Currently it
194 /// only handles synthesizing norecurse attributes.
195 ///
197 
198 //===----------------------------------------------------------------------===//
199 /// createMergeFunctionsPass - This pass discovers identical functions and
200 /// collapses them.
201 ///
202 ModulePass *createMergeFunctionsPass();
203 
204 //===----------------------------------------------------------------------===//
205 /// createPartialInliningPass - This pass inlines parts of functions.
206 ///
207 ModulePass *createPartialInliningPass();
208 
209 //===----------------------------------------------------------------------===//
210 // createMetaRenamerPass - Rename everything with metasyntatic names.
211 //
212 ModulePass *createMetaRenamerPass();
213 
214 //===----------------------------------------------------------------------===//
215 /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
216 /// manager.
217 ModulePass *createBarrierNoopPass();
218 
219 /// createCalledValuePropagationPass - Attach metadata to indirct call sites
220 /// indicating the set of functions they may target at run-time.
222 
223 /// What to do with the summary when running passes that operate on it.
224 enum class PassSummaryAction {
225  None, ///< Do nothing.
226  Import, ///< Import information from summary.
227  Export, ///< Export information to summary.
228 };
229 
230 /// \brief This pass lowers type metadata and the llvm.type.test intrinsic to
231 /// bitsets.
232 ///
233 /// The behavior depends on the summary arguments:
234 /// - If ExportSummary is non-null, this pass will export type identifiers to
235 /// the given summary.
236 /// - Otherwise, if ImportSummary is non-null, this pass will import type
237 /// identifiers from the given summary.
238 /// - Otherwise it does neither.
239 /// It is invalid for both ExportSummary and ImportSummary to be non-null.
241  const ModuleSummaryIndex *ImportSummary);
242 
243 /// \brief This pass export CFI checks for use by external modules.
245 
246 /// \brief This pass implements whole-program devirtualization using type
247 /// metadata.
248 ///
249 /// The behavior depends on the summary arguments:
250 /// - If ExportSummary is non-null, this pass will export type identifiers to
251 /// the given summary.
252 /// - Otherwise, if ImportSummary is non-null, this pass will import type
253 /// identifiers from the given summary.
254 /// - Otherwise it does neither.
255 /// It is invalid for both ExportSummary and ImportSummary to be non-null.
256 ModulePass *
258  const ModuleSummaryIndex *ImportSummary);
259 
260 /// This pass splits globals into pieces for the benefit of whole-program
261 /// devirtualization and control-flow integrity.
263 
264 //===----------------------------------------------------------------------===//
265 // SampleProfilePass - Loads sample profile data from disk and generates
266 // IR metadata to reflect the profile.
269 
270 /// Write ThinLTO-ready bitcode to Str.
272  raw_ostream *ThinLinkOS = nullptr);
273 
274 } // End llvm namespace
275 
276 #endif
ModulePass * createWriteThinLTOBitcodePass(raw_ostream &Str, raw_ostream *ThinLinkOS=nullptr)
Write ThinLTO-ready bitcode to Str.
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...
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
PassSummaryAction
What to do with the summary when running passes that operate on it.
Definition: IPO.h:224
Various leaf nodes.
Definition: ISDOpcodes.h:60
ModulePass * createMergeFunctionsPass()
createMergeFunctionsPass - This pass discovers identical functions and collapses them.
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
ModulePass * createIPSCCPPass()
createIPSCCPPass - This pass propagates constants from call sites into the bodies of functions...
Definition: SCCP.cpp:2047
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()
Export information to summary.
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 * createMetaRenamerPass()
ModulePass * createCalledValuePropagationPass()
createCalledValuePropagationPass - Attach metadata to indirct call sites indicating the set of functi...
ModulePass * createSampleProfileLoaderPass()
Class to hold module path string table and global value map, and encapsulate methods for operating on...
ModulePass * createGlobalDCEPass()
createGlobalDCEPass - This transform is designed to eliminate unreachable internal globals (functions...
Import information from summary.
Pass * createFunctionImportPass()
This pass performs iterative function importing from other modules.
ModulePass * createDeadArgEliminationPass()
createDeadArgEliminationPass - This pass removes arguments from functions which are not used by the b...
ModulePass * createLowerTypeTestsPass(ModuleSummaryIndex *ExportSummary, const ModuleSummaryIndex *ImportSummary)
This pass lowers type metadata and the llvm.type.test intrinsic to bitsets.
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:2725
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...
print lazy value Lazy Value Info Printer Pass
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 * createWholeProgramDevirtPass(ModuleSummaryIndex *ExportSummary, const ModuleSummaryIndex *ImportSummary)
This pass implements whole-program devirtualization using type metadata.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:225
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)
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
print Print MemDeps of function
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49