4372ea00d42acf26c589d7f4c3511593c8b75492
[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 <vector>
19
20 namespace llvm {
21
22 class FunctionPass;
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 /// createLowerSetJmpPass - This function lowers the setjmp/longjmp intrinsics
50 /// to invoke/unwind instructions.  This should really be part of the C/C++
51 /// front-end, but it's so much easier to write transformations in LLVM proper.
52 ///
53 ModulePass *createLowerSetJmpPass();
54
55 //===----------------------------------------------------------------------===//
56 /// createConstantMergePass - This function returns a new pass that merges
57 /// duplicate global constants together into a single constant that is shared.
58 /// This is useful because some passes (ie TraceValues) insert a lot of string
59 /// constants into the program, regardless of whether or not they duplicate an
60 /// existing string.
61 ///
62 ModulePass *createConstantMergePass();
63
64
65 //===----------------------------------------------------------------------===//
66 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
67 /// non-address taken internal globals.
68 ///
69 ModulePass *createGlobalOptimizerPass();
70
71
72 //===----------------------------------------------------------------------===//
73 /// createRaiseAllocationsPass - Return a new pass that transforms malloc and
74 /// free function calls into malloc and free instructions.
75 ///
76 ModulePass *createRaiseAllocationsPass();
77
78
79 //===----------------------------------------------------------------------===//
80 /// createDeadTypeEliminationPass - Return a new pass that eliminates symbol
81 /// table entries for types that are never used.
82 ///
83 ModulePass *createDeadTypeEliminationPass();
84
85
86 //===----------------------------------------------------------------------===//
87 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
88 /// internal globals (functions or global variables)
89 ///
90 ModulePass *createGlobalDCEPass();
91
92
93 //===----------------------------------------------------------------------===//
94 /// createGVExtractionPass - If deleteFn is true, this pass deletes as
95 /// the specified global values. Otherwise, it deletes as much of the module as
96 /// possible, except for the global values specified.
97 ///
98 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool 
99                                    deleteFn = false, 
100                                    bool relinkCallees = false);
101
102 //===----------------------------------------------------------------------===//
103 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
104 /// to inline direct function calls to small functions.
105 ///
106 Pass *createFunctionInliningPass();
107 Pass *createFunctionInliningPass(int Threshold);
108
109 //===----------------------------------------------------------------------===//
110 /// createAlwaysInlinerPass - Return a new pass object that inlines only 
111 /// functions that are marked as "always_inline".
112 Pass *createAlwaysInlinerPass();
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) not part
123 /// of the api.  If a list of symbols is specified with the
124 /// -internalize-public-api-* command line options, those symbols are not
125 /// internalized and all others are.  Otherwise if AllButMain is set and the
126 /// main function is found, all other globals are marked as internal. If no api
127 /// is supplied and AllButMain is not set, or no main function is found, nothing
128 /// is internalized.
129 ///
130 ModulePass *createInternalizePass(bool AllButMain);
131
132 /// createInternalizePass - This pass loops over all of the functions in the
133 /// input module, internalizing all globals (functions and variables) not in the
134 /// given exportList.
135 ///
136 /// Note that commandline options that are used with the above function are not
137 /// used now! Also, when exportList is empty, nothing is internalized.
138 ModulePass *createInternalizePass(const std::vector<const char *> &exportList);
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 Pass *createStructRetPromotionPass();
158
159 //===----------------------------------------------------------------------===//
160 /// createIPConstantPropagationPass - This pass propagates constants from call
161 /// sites into the bodies of functions.
162 ///
163 ModulePass *createIPConstantPropagationPass();
164
165 //===----------------------------------------------------------------------===//
166 /// createIPSCCPPass - This pass propagates constants from call sites into the
167 /// bodies of functions, and keeps track of whether basic blocks are executable
168 /// in the process.
169 ///
170 ModulePass *createIPSCCPPass();
171
172 //===----------------------------------------------------------------------===//
173 //
174 /// createLoopExtractorPass - This pass extracts all natural loops from the
175 /// program into a function if it can.
176 ///
177 FunctionPass *createLoopExtractorPass();
178
179 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
180 /// program into a function if it can.  This is used by bugpoint.
181 ///
182 FunctionPass *createSingleLoopExtractorPass();
183
184 /// createBlockExtractorPass - This pass extracts all blocks (except those
185 /// specified in the argument list) from the functions in the module.
186 ///
187 ModulePass *createBlockExtractorPass(const std::vector<BasicBlock*> &BTNE);
188
189 /// createIndMemRemPass - This pass removes potential indirect calls of
190 /// malloc and free
191 ModulePass *createIndMemRemPass();
192
193 /// createStripDeadPrototypesPass - This pass removes any function declarations
194 /// (prototypes) that are not used.
195 ModulePass *createStripDeadPrototypesPass();
196
197 //===----------------------------------------------------------------------===//
198 /// createPartialSpecializationPass - This pass specializes functions for
199 /// constant arguments.
200 ///
201 ModulePass *createPartialSpecializationPass();
202
203 //===----------------------------------------------------------------------===//
204 /// createFunctionAttrsPass - This pass discovers functions that do not access
205 /// memory, or only read memory, and gives them the readnone/readonly attribute.
206 /// It also discovers function arguments that are not captured by the function
207 /// and marks them with the nocapture attribute.
208 ///
209 Pass *createFunctionAttrsPass();
210
211 //===----------------------------------------------------------------------===//
212 /// createMergeFunctionsPass - This pass discovers identical functions and
213 /// collapses them.
214 ///
215 ModulePass *createMergeFunctionsPass();
216
217 } // End llvm namespace
218
219 #endif