remove the IndMemRemPass, which only made sense for when malloc/free were intrinsic
[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 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 /// createLowerSetJmpPass - This function lowers the setjmp/longjmp intrinsics
49 /// to invoke/unwind instructions.  This should really be part of the C/C++
50 /// front-end, but it's so much easier to write transformations in LLVM proper.
51 ///
52 ModulePass *createLowerSetJmpPass();
53
54 //===----------------------------------------------------------------------===//
55 /// createConstantMergePass - This function returns a new pass that merges
56 /// duplicate global constants together into a single constant that is shared.
57 /// This is useful because some passes (ie TraceValues) insert a lot of string
58 /// constants into the program, regardless of whether or not they duplicate an
59 /// existing string.
60 ///
61 ModulePass *createConstantMergePass();
62
63
64 //===----------------------------------------------------------------------===//
65 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
66 /// non-address taken internal globals.
67 ///
68 ModulePass *createGlobalOptimizerPass();
69
70
71 //===----------------------------------------------------------------------===//
72 /// createRaiseAllocationsPass - Return a new pass that transforms malloc and
73 /// free function calls into malloc and free instructions.
74 ///
75 ModulePass *createRaiseAllocationsPass();
76
77
78 //===----------------------------------------------------------------------===//
79 /// createDeadTypeEliminationPass - Return a new pass that eliminates symbol
80 /// table entries for types that are never used.
81 ///
82 ModulePass *createDeadTypeEliminationPass();
83
84
85 //===----------------------------------------------------------------------===//
86 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
87 /// internal globals (functions or global variables)
88 ///
89 ModulePass *createGlobalDCEPass();
90
91
92 //===----------------------------------------------------------------------===//
93 /// createGVExtractionPass - If deleteFn is true, this pass deletes as
94 /// the specified global values. Otherwise, it deletes as much of the module as
95 /// possible, except for the global values specified.
96 ///
97 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool 
98                                    deleteFn = false, 
99                                    bool relinkCallees = false);
100
101 //===----------------------------------------------------------------------===//
102 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
103 /// to inline direct function calls to small functions.
104 ///
105 Pass *createFunctionInliningPass();
106 Pass *createFunctionInliningPass(int Threshold);
107
108 //===----------------------------------------------------------------------===//
109 /// createAlwaysInlinerPass - Return a new pass object that inlines only 
110 /// functions that are marked as "always_inline".
111 Pass *createAlwaysInlinerPass();
112
113 //===----------------------------------------------------------------------===//
114 /// createPruneEHPass - Return a new pass object which transforms invoke
115 /// instructions into calls, if the callee can _not_ unwind the stack.
116 ///
117 Pass *createPruneEHPass();
118
119 //===----------------------------------------------------------------------===//
120 /// createInternalizePass - This pass loops over all of the functions in the
121 /// input module, internalizing all globals (functions and variables) not part
122 /// of the api.  If a list of symbols is specified with the
123 /// -internalize-public-api-* command line options, those symbols are not
124 /// internalized and all others are.  Otherwise if AllButMain is set and the
125 /// main function is found, all other globals are marked as internal. If no api
126 /// is supplied and AllButMain is not set, or no main function is found, nothing
127 /// is internalized.
128 ///
129 ModulePass *createInternalizePass(bool AllButMain);
130
131 /// createInternalizePass - This pass loops over all of the functions in the
132 /// input module, internalizing all globals (functions and variables) not in the
133 /// given exportList.
134 ///
135 /// Note that commandline options that are used with the above function are not
136 /// used now! Also, when exportList is empty, nothing is internalized.
137 ModulePass *createInternalizePass(const std::vector<const char *> &exportList);
138
139 //===----------------------------------------------------------------------===//
140 /// createDeadArgEliminationPass - This pass removes arguments from functions
141 /// which are not used by the body of the function.
142 ///
143 ModulePass *createDeadArgEliminationPass();
144
145 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
146 /// functions as well.  This is definitely not safe, and should only be used by
147 /// bugpoint.
148 ModulePass *createDeadArgHackingPass();
149
150 //===----------------------------------------------------------------------===//
151 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
152 /// be passed by value if the number of elements passed is smaller or
153 /// equal to maxElements (maxElements == 0 means always promote).
154 ///
155 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
156 Pass *createStructRetPromotionPass();
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 ///
176 Pass *createLoopExtractorPass();
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 ///
181 Pass *createSingleLoopExtractorPass();
182
183 /// createBlockExtractorPass - This pass extracts all blocks (except those
184 /// specified in the argument list) from the functions in the module.
185 ///
186 ModulePass *createBlockExtractorPass(const std::vector<BasicBlock*> &BTNE);
187
188 /// createStripDeadPrototypesPass - This pass removes any function declarations
189 /// (prototypes) that are not used.
190 ModulePass *createStripDeadPrototypesPass();
191
192 //===----------------------------------------------------------------------===//
193 /// createPartialSpecializationPass - This pass specializes functions for
194 /// constant arguments.
195 ///
196 ModulePass *createPartialSpecializationPass();
197
198 //===----------------------------------------------------------------------===//
199 /// createFunctionAttrsPass - This pass discovers functions that do not access
200 /// memory, or only read memory, and gives them the readnone/readonly attribute.
201 /// It also discovers function arguments that are not captured by the function
202 /// and marks them with the nocapture attribute.
203 ///
204 Pass *createFunctionAttrsPass();
205
206 //===----------------------------------------------------------------------===//
207 /// createMergeFunctionsPass - This pass discovers identical functions and
208 /// collapses them.
209 ///
210 ModulePass *createMergeFunctionsPass();
211
212 //===----------------------------------------------------------------------===//
213 /// createPartialInliningPass - This pass inlines parts of functions.
214 ///
215 ModulePass *createPartialInliningPass();
216
217 } // End llvm namespace
218
219 #endif