Add new helper pass that strips all symbol names except debugging information.
[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 removes symbols from functions and modules.  
39 // Only debugging information is not removed.
40 //
41 ModulePass *createStripNonDebugSymbolsPass();
42
43 //===----------------------------------------------------------------------===//
44 /// createLowerSetJmpPass - This function lowers the setjmp/longjmp intrinsics
45 /// to invoke/unwind instructions.  This should really be part of the C/C++
46 /// front-end, but it's so much easier to write transformations in LLVM proper.
47 ///
48 ModulePass *createLowerSetJmpPass();
49
50 //===----------------------------------------------------------------------===//
51 /// createConstantMergePass - This function returns a new pass that merges
52 /// duplicate global constants together into a single constant that is shared.
53 /// This is useful because some passes (ie TraceValues) insert a lot of string
54 /// constants into the program, regardless of whether or not they duplicate an
55 /// existing string.
56 ///
57 ModulePass *createConstantMergePass();
58
59
60 //===----------------------------------------------------------------------===//
61 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
62 /// non-address taken internal globals.
63 ///
64 ModulePass *createGlobalOptimizerPass();
65
66
67 //===----------------------------------------------------------------------===//
68 /// createRaiseAllocationsPass - Return a new pass that transforms malloc and
69 /// free function calls into malloc and free instructions.
70 ///
71 ModulePass *createRaiseAllocationsPass();
72
73
74 //===----------------------------------------------------------------------===//
75 /// createDeadTypeEliminationPass - Return a new pass that eliminates symbol
76 /// table entries for types that are never used.
77 ///
78 ModulePass *createDeadTypeEliminationPass();
79
80
81 //===----------------------------------------------------------------------===//
82 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
83 /// internal globals (functions or global variables)
84 ///
85 ModulePass *createGlobalDCEPass();
86
87
88 //===----------------------------------------------------------------------===//
89 /// createGVExtractionPass - If deleteFn is true, this pass deletes as
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                                    bool relinkCallees = false);
96
97 //===----------------------------------------------------------------------===//
98 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
99 /// to inline direct function calls to small functions.
100 ///
101 Pass *createFunctionInliningPass();
102 Pass *createFunctionInliningPass(int Threshold);
103
104 //===----------------------------------------------------------------------===//
105 /// createAlwaysInlinerPass - Return a new pass object that inlines only 
106 /// functions that are marked as "always_inline".
107 Pass *createAlwaysInlinerPass();
108
109 //===----------------------------------------------------------------------===//
110 /// createPruneEHPass - Return a new pass object which transforms invoke
111 /// instructions into calls, if the callee can _not_ unwind the stack.
112 ///
113 Pass *createPruneEHPass();
114
115 //===----------------------------------------------------------------------===//
116 /// createInternalizePass - This pass loops over all of the functions in the
117 /// input module, internalizing all globals (functions and variables) not part
118 /// of the api.  If a list of symbols is specified with the
119 /// -internalize-public-api-* command line options, those symbols are not
120 /// internalized and all others are.  Otherwise if AllButMain is set and the
121 /// main function is found, all other globals are marked as internal. If no api
122 /// is supplied and AllButMain is not set, or no main function is found, nothing
123 /// is internalized.
124 ///
125 ModulePass *createInternalizePass(bool AllButMain);
126
127 /// createInternalizePass - This pass loops over all of the functions in the
128 /// input module, internalizing all globals (functions and variables) not in the
129 /// given exportList.
130 ///
131 /// Note that commandline options that are used with the above function are not
132 /// used now! Also, when exportList is empty, nothing is internalized.
133 ModulePass *createInternalizePass(const std::vector<const char *> &exportList);
134
135 //===----------------------------------------------------------------------===//
136 /// createDeadArgEliminationPass - This pass removes arguments from functions
137 /// which are not used by the body of the function.
138 ///
139 ModulePass *createDeadArgEliminationPass();
140
141 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
142 /// functions as well.  This is definitely not safe, and should only be used by
143 /// bugpoint.
144 ModulePass *createDeadArgHackingPass();
145
146 //===----------------------------------------------------------------------===//
147 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
148 /// be passed by value if the number of elements passed is smaller or
149 /// equal to maxElements (maxElements == 0 means always promote).
150 ///
151 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
152 Pass *createStructRetPromotionPass();
153
154 //===----------------------------------------------------------------------===//
155 /// createIPConstantPropagationPass - This pass propagates constants from call
156 /// sites into the bodies of functions.
157 ///
158 ModulePass *createIPConstantPropagationPass();
159
160 //===----------------------------------------------------------------------===//
161 /// createIPSCCPPass - This pass propagates constants from call sites into the
162 /// bodies of functions, and keeps track of whether basic blocks are executable
163 /// in the process.
164 ///
165 ModulePass *createIPSCCPPass();
166
167 //===----------------------------------------------------------------------===//
168 //
169 /// createLoopExtractorPass - This pass extracts all natural loops from the
170 /// program into a function if it can.
171 ///
172 FunctionPass *createLoopExtractorPass();
173
174 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
175 /// program into a function if it can.  This is used by bugpoint.
176 ///
177 FunctionPass *createSingleLoopExtractorPass();
178
179 /// createBlockExtractorPass - This pass extracts all blocks (except those
180 /// specified in the argument list) from the functions in the module.
181 ///
182 ModulePass *createBlockExtractorPass(const std::vector<BasicBlock*> &BTNE);
183
184 /// createIndMemRemPass - This pass removes potential indirect calls of
185 /// malloc and free
186 ModulePass *createIndMemRemPass();
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 /// createAddReadAttrsPass - This pass discovers functions that do not access
200 /// memory, or only read memory, and gives them the readnone/readonly attribute.
201 ///
202 Pass *createAddReadAttrsPass();
203
204 //===----------------------------------------------------------------------===//
205 /// createMergeFunctionsPass - This pass discovers identical functions and
206 /// collapses them.
207 ///
208 ModulePass *createMergeFunctionsPass();
209
210 } // End llvm namespace
211
212 #endif