96ddc6eceed236f6ad960eac280aafc4683a97ba
[oota-llvm.git] / 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 "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/StringRef.h"
20
21 namespace llvm {
22
23 class ModulePass;
24 class Pass;
25 class Function;
26 class BasicBlock;
27 class GlobalValue;
28
29 //===----------------------------------------------------------------------===//
30 //
31 // These functions removes symbols from functions and modules.  If OnlyDebugInfo
32 // is true, only debugging information is removed from the module.
33 //
34 ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
35
36 //===----------------------------------------------------------------------===//
37 //
38 // These functions strips symbols from functions and modules.
39 // Only debugging information is not stripped.
40 //
41 ModulePass *createStripNonDebugSymbolsPass();
42
43 //===----------------------------------------------------------------------===//
44 //
45 // These pass removes llvm.dbg.declare intrinsics.
46 ModulePass *createStripDebugDeclarePass();
47
48 //===----------------------------------------------------------------------===//
49 //
50 // These pass removes unused symbols' debug info.
51 ModulePass *createStripDeadDebugInfoPass();
52
53 //===----------------------------------------------------------------------===//
54 /// createConstantMergePass - This function returns a new pass that merges
55 /// duplicate global constants together into a single constant that is shared.
56 /// This is useful because some passes (ie TraceValues) insert a lot of string
57 /// constants into the program, regardless of whether or not they duplicate an
58 /// existing string.
59 ///
60 ModulePass *createConstantMergePass();
61
62 //===----------------------------------------------------------------------===//
63 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
64 /// non-address taken internal globals.
65 ///
66 ModulePass *createGlobalOptimizerPass();
67
68 //===----------------------------------------------------------------------===//
69 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
70 /// internal globals (functions or global variables)
71 ///
72 ModulePass *createGlobalDCEPass();
73
74 //===----------------------------------------------------------------------===//
75 /// This transform is designed to eliminate available external globals
76 /// (functions or global variables)
77 ///
78 ModulePass *createEliminateAvailableExternallyPass();
79
80 //===----------------------------------------------------------------------===//
81 /// createGVExtractionPass - If deleteFn is true, this pass deletes
82 /// the specified global values. Otherwise, it deletes as much of the module as
83 /// possible, except for the global values specified.
84 ///
85 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
86                                    deleteFn = false);
87
88 //===----------------------------------------------------------------------===//
89 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
90 /// to inline direct function calls to small functions.
91 ///
92 /// The Threshold can be passed directly, or asked to be computed from the
93 /// given optimization and size optimization arguments.
94 ///
95 /// The -inline-threshold command line option takes precedence over the
96 /// threshold given here.
97 Pass *createFunctionInliningPass();
98 Pass *createFunctionInliningPass(int Threshold);
99 Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel);
100
101 //===----------------------------------------------------------------------===//
102 /// createAlwaysInlinerPass - Return a new pass object that inlines only
103 /// functions that are marked as "always_inline".
104 Pass *createAlwaysInlinerPass();
105 Pass *createAlwaysInlinerPass(bool InsertLifetime);
106
107 //===----------------------------------------------------------------------===//
108 /// createPruneEHPass - Return a new pass object which transforms invoke
109 /// instructions into calls, if the callee can _not_ unwind the stack.
110 ///
111 Pass *createPruneEHPass();
112
113 //===----------------------------------------------------------------------===//
114 /// createInternalizePass - This pass loops over all of the functions in the
115 /// input module, internalizing all globals (functions and variables) it can.
116 ////
117 /// The symbols in \p ExportList are never internalized.
118 ///
119 /// The symbol in DSOList are internalized if it is safe to drop them from
120 /// the symbol table.
121 ///
122 /// Note that commandline options that are used with the above function are not
123 /// used now!
124 ModulePass *createInternalizePass(ArrayRef<const char *> ExportList);
125 /// createInternalizePass - Same as above, but with an empty exportList.
126 ModulePass *createInternalizePass();
127
128 //===----------------------------------------------------------------------===//
129 /// createDeadArgEliminationPass - This pass removes arguments from functions
130 /// which are not used by the body of the function.
131 ///
132 ModulePass *createDeadArgEliminationPass();
133
134 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
135 /// functions as well.  This is definitely not safe, and should only be used by
136 /// bugpoint.
137 ModulePass *createDeadArgHackingPass();
138
139 //===----------------------------------------------------------------------===//
140 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
141 /// be passed by value if the number of elements passed is smaller or
142 /// equal to maxElements (maxElements == 0 means always promote).
143 ///
144 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
145
146 //===----------------------------------------------------------------------===//
147 /// createIPConstantPropagationPass - This pass propagates constants from call
148 /// sites into the bodies of functions.
149 ///
150 ModulePass *createIPConstantPropagationPass();
151
152 //===----------------------------------------------------------------------===//
153 /// createIPSCCPPass - This pass propagates constants from call sites into the
154 /// bodies of functions, and keeps track of whether basic blocks are executable
155 /// in the process.
156 ///
157 ModulePass *createIPSCCPPass();
158
159 //===----------------------------------------------------------------------===//
160 //
161 /// createLoopExtractorPass - This pass extracts all natural loops from the
162 /// program into a function if it can.
163 ///
164 Pass *createLoopExtractorPass();
165
166 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
167 /// program into a function if it can.  This is used by bugpoint.
168 ///
169 Pass *createSingleLoopExtractorPass();
170
171 /// createBlockExtractorPass - This pass extracts all blocks (except those
172 /// specified in the argument list) from the functions in the module.
173 ///
174 ModulePass *createBlockExtractorPass();
175
176 /// createStripDeadPrototypesPass - This pass removes any function declarations
177 /// (prototypes) that are not used.
178 ModulePass *createStripDeadPrototypesPass();
179
180 //===----------------------------------------------------------------------===//
181 /// createFunctionAttrsPass - This pass discovers functions that do not access
182 /// memory, or only read memory, and gives them the readnone/readonly attribute.
183 /// It also discovers function arguments that are not captured by the function
184 /// and marks them with the nocapture attribute.
185 ///
186 Pass *createFunctionAttrsPass();
187
188 //===----------------------------------------------------------------------===//
189 /// createMergeFunctionsPass - This pass discovers identical functions and
190 /// collapses them.
191 ///
192 ModulePass *createMergeFunctionsPass();
193
194 //===----------------------------------------------------------------------===//
195 /// createPartialInliningPass - This pass inlines parts of functions.
196 ///
197 ModulePass *createPartialInliningPass();
198
199 //===----------------------------------------------------------------------===//
200 // createMetaRenamerPass - Rename everything with metasyntatic names.
201 //
202 ModulePass *createMetaRenamerPass();
203
204 //===----------------------------------------------------------------------===//
205 /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
206 /// manager.
207 ModulePass *createBarrierNoopPass();
208
209 /// \brief This pass lowers bitset metadata and the llvm.bitset.test intrinsic
210 /// to bitsets.
211 ModulePass *createLowerBitSetsPass();
212
213 //===----------------------------------------------------------------------===//
214 // SampleProfilePass - Loads sample profile data from disk and generates
215 // IR metadata to reflect the profile.
216 ModulePass *createSampleProfileLoaderPass();
217 ModulePass *createSampleProfileLoaderPass(StringRef Name);
218
219 } // End llvm namespace
220
221 #endif