]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/Transforms/IPO.h
Merge llvm, clang, lld and lldb trunk r291274, and resolve conflicts.
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / Transforms / IPO.h
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.
49 ModulePass *createStripNonLineTableDebugInfoPass();
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 ///
86 ModulePass *createEliminateAvailableExternallyPass();
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.
98 Pass *createFunctionImportPass();
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.
109 Pass *createFunctionInliningPass();
110 Pass *createFunctionInliningPass(int Threshold);
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 ///
118 Pass *createPruneEHPass();
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 ///
174 Pass *createLoopExtractorPass();
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 ///
179 Pass *createSingleLoopExtractorPass();
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 ///
195 Pass *createReversePostOrderFunctionAttrsPass();
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 /// \brief This pass lowers type metadata and the llvm.type.test intrinsic to
219 /// bitsets.
220 ModulePass *createLowerTypeTestsPass();
221
222 /// \brief This pass export CFI checks for use by external modules.
223 ModulePass *createCrossDSOCFIPass();
224
225 /// \brief This pass implements whole-program devirtualization using type
226 /// metadata.
227 ModulePass *createWholeProgramDevirtPass();
228
229 /// This pass splits globals into pieces for the benefit of whole-program
230 /// devirtualization and control-flow integrity.
231 ModulePass *createGlobalSplitPass();
232
233 //===----------------------------------------------------------------------===//
234 // SampleProfilePass - Loads sample profile data from disk and generates
235 // IR metadata to reflect the profile.
236 ModulePass *createSampleProfileLoaderPass();
237 ModulePass *createSampleProfileLoaderPass(StringRef Name);
238
239 /// Write ThinLTO-ready bitcode to Str.
240 ModulePass *createWriteThinLTOBitcodePass(raw_ostream &Str);
241
242 } // End llvm namespace
243
244 #endif