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 /// This function returns a new pass that downgrades the debug info in the
49 /// module to line tables only.
51 
52 //===----------------------------------------------------------------------===//
53 //
54 // This pass removes llvm.dbg.declare intrinsics.
55 ModulePass *createStripDebugDeclarePass();
56 
57 //===----------------------------------------------------------------------===//
58 //
59 // This pass removes unused symbols' debug info.
60 ModulePass *createStripDeadDebugInfoPass();
61 
62 //===----------------------------------------------------------------------===//
63 /// createConstantMergePass - This function returns a new pass that merges
64 /// duplicate global constants together into a single constant that is shared.
65 /// This is useful because some passes (ie TraceValues) insert a lot of string
66 /// constants into the program, regardless of whether or not they duplicate an
67 /// existing string.
68 ///
69 ModulePass *createConstantMergePass();
70 
71 //===----------------------------------------------------------------------===//
72 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
73 /// non-address taken internal globals.
74 ///
75 ModulePass *createGlobalOptimizerPass();
76 
77 //===----------------------------------------------------------------------===//
78 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
79 /// internal globals (functions or global variables)
80 ///
81 ModulePass *createGlobalDCEPass();
82 
83 //===----------------------------------------------------------------------===//
84 /// This transform is designed to eliminate available external globals
85 /// (functions or global variables)
86 ///
88 
89 //===----------------------------------------------------------------------===//
90 /// createGVExtractionPass - If deleteFn is true, this pass deletes
91 /// the specified global values. Otherwise, it deletes as much of the module as
92 /// possible, except for the global values specified.
93 ///
94 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
95  deleteFn = false);
96 
97 //===----------------------------------------------------------------------===//
98 /// This pass performs iterative function importing from other modules.
100 
101 //===----------------------------------------------------------------------===//
102 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
103 /// to inline direct function calls to small functions.
104 ///
105 /// The Threshold can be passed directly, or asked to be computed from the
106 /// given optimization and size optimization arguments.
107 ///
108 /// The -inline-threshold command line option takes precedence over the
109 /// threshold given here.
112 Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel,
113  bool DisableInlineHotCallSite);
114 Pass *createFunctionInliningPass(InlineParams &Params);
115 
116 //===----------------------------------------------------------------------===//
117 /// createPruneEHPass - Return a new pass object which transforms invoke
118 /// instructions into calls, if the callee can _not_ unwind the stack.
119 ///
121 
122 //===----------------------------------------------------------------------===//
123 /// createInternalizePass - This pass loops over all of the functions in the
124 /// input module, internalizing all globals (functions and variables) it can.
125 ////
126 /// Before internalizing a symbol, the callback \p MustPreserveGV is invoked and
127 /// gives to the client the ability to prevent internalizing specific symbols.
128 ///
129 /// The symbol in DSOList are internalized if it is safe to drop them from
130 /// the symbol table.
131 ///
132 /// Note that commandline options that are used with the above function are not
133 /// used now!
134 ModulePass *
135 createInternalizePass(std::function<bool(const GlobalValue &)> MustPreserveGV);
136 
137 /// createInternalizePass - Same as above, but with an empty exportList.
138 ModulePass *createInternalizePass();
139 
140 //===----------------------------------------------------------------------===//
141 /// createDeadArgEliminationPass - This pass removes arguments from functions
142 /// which are not used by the body of the function.
143 ///
144 ModulePass *createDeadArgEliminationPass();
145 
146 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
147 /// functions as well. This is definitely not safe, and should only be used by
148 /// bugpoint.
149 ModulePass *createDeadArgHackingPass();
150 
151 //===----------------------------------------------------------------------===//
152 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
153 /// be passed by value if the number of elements passed is smaller or
154 /// equal to maxElements (maxElements == 0 means always promote).
155 ///
156 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
157 
158 //===----------------------------------------------------------------------===//
159 /// createIPConstantPropagationPass - This pass propagates constants from call
160 /// sites into the bodies of functions.
161 ///
162 ModulePass *createIPConstantPropagationPass();
163 
164 //===----------------------------------------------------------------------===//
165 /// createIPSCCPPass - This pass propagates constants from call sites into the
166 /// bodies of functions, and keeps track of whether basic blocks are executable
167 /// in the process.
168 ///
169 ModulePass *createIPSCCPPass();
170 
171 //===----------------------------------------------------------------------===//
172 //
173 /// createLoopExtractorPass - This pass extracts all natural loops from the
174 /// program into a function if it can.
175 ///
177 
178 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
179 /// program into a function if it can. This is used by bugpoint.
180 ///
182 
183 /// createBlockExtractorPass - This pass extracts all the specified blocks
184 /// from the functions in the module.
185 ///
186 ModulePass *createBlockExtractorPass();
187 ModulePass *
188 createBlockExtractorPass(const SmallVectorImpl<BasicBlock *> &BlocksToExtract,
189  bool EraseFunctions);
190 
191 /// createStripDeadPrototypesPass - This pass removes any function declarations
192 /// (prototypes) that are not used.
193 ModulePass *createStripDeadPrototypesPass();
194 
195 //===----------------------------------------------------------------------===//
196 /// createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call
197 /// graph in RPO to deduce and propagate function attributes. Currently it
198 /// only handles synthesizing norecurse attributes.
199 ///
201 
202 //===----------------------------------------------------------------------===//
203 /// createMergeFunctionsPass - This pass discovers identical functions and
204 /// collapses them.
205 ///
206 ModulePass *createMergeFunctionsPass();
207 
208 //===----------------------------------------------------------------------===//
209 /// createPartialInliningPass - This pass inlines parts of functions.
210 ///
211 ModulePass *createPartialInliningPass();
212 
213 //===----------------------------------------------------------------------===//
214 // createMetaRenamerPass - Rename everything with metasyntatic names.
215 //
216 ModulePass *createMetaRenamerPass();
217 
218 //===----------------------------------------------------------------------===//
219 /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
220 /// manager.
221 ModulePass *createBarrierNoopPass();
222 
223 /// createCalledValuePropagationPass - Attach metadata to indirct call sites
224 /// indicating the set of functions they may target at run-time.
226 
227 /// What to do with the summary when running passes that operate on it.
228 enum class PassSummaryAction {
229  None, ///< Do nothing.
230  Import, ///< Import information from summary.
231  Export, ///< Export information to summary.
232 };
233 
234 /// \brief This pass lowers type metadata and the llvm.type.test intrinsic to
235 /// bitsets.
236 ///
237 /// The behavior depends on the summary arguments:
238 /// - If ExportSummary is non-null, this pass will export type identifiers to
239 /// the given summary.
240 /// - Otherwise, if ImportSummary is non-null, this pass will import type
241 /// identifiers from the given summary.
242 /// - Otherwise it does neither.
243 /// It is invalid for both ExportSummary and ImportSummary to be non-null.
245  const ModuleSummaryIndex *ImportSummary);
246 
247 /// \brief This pass export CFI checks for use by external modules.
249 
250 /// \brief This pass implements whole-program devirtualization using type
251 /// metadata.
252 ///
253 /// The behavior depends on the summary arguments:
254 /// - If ExportSummary is non-null, this pass will export type identifiers to
255 /// the given summary.
256 /// - Otherwise, if ImportSummary is non-null, this pass will import type
257 /// identifiers from the given summary.
258 /// - Otherwise it does neither.
259 /// It is invalid for both ExportSummary and ImportSummary to be non-null.
260 ModulePass *
262  const ModuleSummaryIndex *ImportSummary);
263 
264 /// This pass splits globals into pieces for the benefit of whole-program
265 /// devirtualization and control-flow integrity.
267 
268 //===----------------------------------------------------------------------===//
269 // SampleProfilePass - Loads sample profile data from disk and generates
270 // IR metadata to reflect the profile.
273 
274 /// Write ThinLTO-ready bitcode to Str.
276  raw_ostream *ThinLinkOS = nullptr);
277 
278 } // End llvm namespace
279 
280 #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:228
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:2045
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 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 * 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:3000
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:44
print Print MemDeps of function
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49