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