LLVM  7.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 "llvm/ADT/SmallVector.h"
19 #include <functional>
20 #include <vector>
21 
22 namespace llvm {
23 
24 struct InlineParams;
25 class StringRef;
26 class ModuleSummaryIndex;
27 class ModulePass;
28 class Pass;
29 class Function;
30 class BasicBlock;
31 class GlobalValue;
32 class raw_ostream;
33 
34 //===----------------------------------------------------------------------===//
35 //
36 // These functions removes symbols from functions and modules. If OnlyDebugInfo
37 // is true, only debugging information is removed from the module.
38 //
39 ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
40 
41 //===----------------------------------------------------------------------===//
42 //
43 // These functions strips symbols from functions and modules.
44 // Only debugging information is not stripped.
45 //
46 ModulePass *createStripNonDebugSymbolsPass();
47 
48 //===----------------------------------------------------------------------===//
49 //
50 // This pass removes llvm.dbg.declare intrinsics.
51 ModulePass *createStripDebugDeclarePass();
52 
53 //===----------------------------------------------------------------------===//
54 //
55 // This pass removes unused symbols' debug info.
56 ModulePass *createStripDeadDebugInfoPass();
57 
58 //===----------------------------------------------------------------------===//
59 /// createConstantMergePass - This function returns a new pass that merges
60 /// duplicate global constants together into a single constant that is shared.
61 /// This is useful because some passes (ie TraceValues) insert a lot of string
62 /// constants into the program, regardless of whether or not they duplicate an
63 /// existing string.
64 ///
65 ModulePass *createConstantMergePass();
66 
67 //===----------------------------------------------------------------------===//
68 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
69 /// non-address taken internal globals.
70 ///
71 ModulePass *createGlobalOptimizerPass();
72 
73 //===----------------------------------------------------------------------===//
74 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
75 /// internal globals (functions or global variables)
76 ///
77 ModulePass *createGlobalDCEPass();
78 
79 //===----------------------------------------------------------------------===//
80 /// This transform is designed to eliminate available external globals
81 /// (functions or global variables)
82 ///
84 
85 //===----------------------------------------------------------------------===//
86 /// createGVExtractionPass - If deleteFn is true, this pass deletes
87 /// the specified global values. Otherwise, it deletes as much of the module as
88 /// possible, except for the global values specified.
89 ///
90 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
91  deleteFn = false);
92 
93 //===----------------------------------------------------------------------===//
94 /// This pass performs iterative function importing from other modules.
96 
97 //===----------------------------------------------------------------------===//
98 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
99 /// to inline direct function calls to small functions.
100 ///
101 /// The Threshold can be passed directly, or asked to be computed from the
102 /// given optimization and size optimization arguments.
103 ///
104 /// The -inline-threshold command line option takes precedence over the
105 /// threshold given here.
108 Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel,
109  bool DisableInlineHotCallSite);
110 Pass *createFunctionInliningPass(InlineParams &Params);
111 
112 //===----------------------------------------------------------------------===//
113 /// createPruneEHPass - Return a new pass object which transforms invoke
114 /// instructions into calls, if the callee can _not_ unwind the stack.
115 ///
117 
118 //===----------------------------------------------------------------------===//
119 /// createInternalizePass - This pass loops over all of the functions in the
120 /// input module, internalizing all globals (functions and variables) it can.
121 ////
122 /// Before internalizing a symbol, the callback \p MustPreserveGV is invoked and
123 /// gives to the client the ability to prevent internalizing specific symbols.
124 ///
125 /// The symbol in DSOList are internalized if it is safe to drop them from
126 /// the symbol table.
127 ///
128 /// Note that commandline options that are used with the above function are not
129 /// used now!
130 ModulePass *
131 createInternalizePass(std::function<bool(const GlobalValue &)> MustPreserveGV);
132 
133 /// createInternalizePass - Same as above, but with an empty exportList.
134 ModulePass *createInternalizePass();
135 
136 //===----------------------------------------------------------------------===//
137 /// createDeadArgEliminationPass - This pass removes arguments from functions
138 /// which are not used by the body of the function.
139 ///
140 ModulePass *createDeadArgEliminationPass();
141 
142 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
143 /// functions as well. This is definitely not safe, and should only be used by
144 /// bugpoint.
145 ModulePass *createDeadArgHackingPass();
146 
147 //===----------------------------------------------------------------------===//
148 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
149 /// be passed by value if the number of elements passed is smaller or
150 /// equal to maxElements (maxElements == 0 means always promote).
151 ///
152 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
153 
154 //===----------------------------------------------------------------------===//
155 /// createIPConstantPropagationPass - This pass propagates constants from call
156 /// sites into the bodies of functions.
157 ///
158 ModulePass *createIPConstantPropagationPass();
159 
160 //===----------------------------------------------------------------------===//
161 /// createIPSCCPPass - This pass propagates constants from call sites into the
162 /// bodies of functions, and keeps track of whether basic blocks are executable
163 /// in the process.
164 ///
165 ModulePass *createIPSCCPPass();
166 
167 //===----------------------------------------------------------------------===//
168 //
169 /// createLoopExtractorPass - This pass extracts all natural loops from the
170 /// program into a function if it can.
171 ///
173 
174 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
175 /// program into a function if it can. This is used by bugpoint.
176 ///
178 
179 /// createBlockExtractorPass - This pass extracts all the specified blocks
180 /// from the functions in the module.
181 ///
182 ModulePass *createBlockExtractorPass();
183 ModulePass *
184 createBlockExtractorPass(const SmallVectorImpl<BasicBlock *> &BlocksToExtract,
185  bool EraseFunctions);
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 /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
211 /// manager.
212 ModulePass *createBarrierNoopPass();
213 
214 /// createCalledValuePropagationPass - Attach metadata to indirct call sites
215 /// indicating the set of functions they may target at run-time.
217 
218 /// What to do with the summary when running passes that operate on it.
219 enum class PassSummaryAction {
220  None, ///< Do nothing.
221  Import, ///< Import information from summary.
222  Export, ///< Export information to summary.
223 };
224 
225 /// This pass lowers type metadata and the llvm.type.test intrinsic to
226 /// bitsets.
227 ///
228 /// The behavior depends on the summary arguments:
229 /// - If ExportSummary is non-null, this pass will export type identifiers to
230 /// the given summary.
231 /// - Otherwise, if ImportSummary is non-null, this pass will import type
232 /// identifiers from the given summary.
233 /// - Otherwise it does neither.
234 /// It is invalid for both ExportSummary and ImportSummary to be non-null.
236  const ModuleSummaryIndex *ImportSummary);
237 
238 /// This pass export CFI checks for use by external modules.
240 
241 /// This pass implements whole-program devirtualization using type
242 /// metadata.
243 ///
244 /// The behavior depends on the summary arguments:
245 /// - If ExportSummary is non-null, this pass will export type identifiers to
246 /// the given summary.
247 /// - Otherwise, if ImportSummary is non-null, this pass will import type
248 /// identifiers from the given summary.
249 /// - Otherwise it does neither.
250 /// It is invalid for both ExportSummary and ImportSummary to be non-null.
251 ModulePass *
253  const ModuleSummaryIndex *ImportSummary);
254 
255 /// This pass splits globals into pieces for the benefit of whole-program
256 /// devirtualization and control-flow integrity.
258 
259 //===----------------------------------------------------------------------===//
260 // SampleProfilePass - Loads sample profile data from disk and generates
261 // IR metadata to reflect the profile.
264 
265 /// Write ThinLTO-ready bitcode to Str.
267  raw_ostream *ThinLinkOS = nullptr);
268 
269 } // End llvm namespace
270 
271 #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:219
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:158
ModulePass * createIPSCCPPass()
createIPSCCPPass - This pass propagates constants from call sites into the bodies of functions...
Definition: SCCP.cpp:58
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 the specified blocks from the functions in the modu...
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 * 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:3026
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:61
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:46
print Print MemDeps of function
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49