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