Add new EliminateAvailableExternally module pass, which is performed in
[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 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
63 /// non-address taken internal globals.
64 ///
65 ModulePass *createGlobalOptimizerPass();
66
67 //===----------------------------------------------------------------------===//
68 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
69 /// internal globals (functions or global variables)
70 ///
71 ModulePass *createGlobalDCEPass();
72
73 //===----------------------------------------------------------------------===//
74 /// This transform is designed to eliminate available external globals
75 /// (functions or global variables)
76 ///
77 ModulePass *createEliminateAvailableExternallyPass();
78
79 //===----------------------------------------------------------------------===//
80 /// createGVExtractionPass - If deleteFn is true, this pass deletes
81 /// the specified global values. Otherwise, it deletes as much of the module as
82 /// possible, except for the global values specified.
83 ///
84 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
85                                    deleteFn = false);
86
87 //===----------------------------------------------------------------------===//
88 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
89 /// to inline direct function calls to small functions.
90 ///
91 /// The Threshold can be passed directly, or asked to be computed from the
92 /// given optimization and size optimization arguments.
93 ///
94 /// The -inline-threshold command line option takes precedence over the
95 /// threshold given here.
96 Pass *createFunctionInliningPass();
97 Pass *createFunctionInliningPass(int Threshold);
98 Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel);
99
100 //===----------------------------------------------------------------------===//
101 /// createAlwaysInlinerPass - Return a new pass object that inlines only
102 /// functions that are marked as "always_inline".
103 Pass *createAlwaysInlinerPass();
104 Pass *createAlwaysInlinerPass(bool InsertLifetime);
105
106 //===----------------------------------------------------------------------===//
107 /// createPruneEHPass - Return a new pass object which transforms invoke
108 /// instructions into calls, if the callee can _not_ unwind the stack.
109 ///
110 Pass *createPruneEHPass();
111
112 //===----------------------------------------------------------------------===//
113 /// createInternalizePass - This pass loops over all of the functions in the
114 /// input module, internalizing all globals (functions and variables) it can.
115 ////
116 /// The symbols in \p ExportList are never internalized.
117 ///
118 /// The symbol in DSOList are internalized if it is safe to drop them from
119 /// the symbol table.
120 ///
121 /// Note that commandline options that are used with the above function are not
122 /// used now!
123 ModulePass *createInternalizePass(ArrayRef<const char *> ExportList);
124 /// createInternalizePass - Same as above, but with an empty exportList.
125 ModulePass *createInternalizePass();
126
127 //===----------------------------------------------------------------------===//
128 /// createDeadArgEliminationPass - This pass removes arguments from functions
129 /// which are not used by the body of the function.
130 ///
131 ModulePass *createDeadArgEliminationPass();
132
133 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
134 /// functions as well.  This is definitely not safe, and should only be used by
135 /// bugpoint.
136 ModulePass *createDeadArgHackingPass();
137
138 //===----------------------------------------------------------------------===//
139 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
140 /// be passed by value if the number of elements passed is smaller or
141 /// equal to maxElements (maxElements == 0 means always promote).
142 ///
143 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
144
145 //===----------------------------------------------------------------------===//
146 /// createIPConstantPropagationPass - This pass propagates constants from call
147 /// sites into the bodies of functions.
148 ///
149 ModulePass *createIPConstantPropagationPass();
150
151 //===----------------------------------------------------------------------===//
152 /// createIPSCCPPass - This pass propagates constants from call sites into the
153 /// bodies of functions, and keeps track of whether basic blocks are executable
154 /// in the process.
155 ///
156 ModulePass *createIPSCCPPass();
157
158 //===----------------------------------------------------------------------===//
159 //
160 /// createLoopExtractorPass - This pass extracts all natural loops from the
161 /// program into a function if it can.
162 ///
163 Pass *createLoopExtractorPass();
164
165 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
166 /// program into a function if it can.  This is used by bugpoint.
167 ///
168 Pass *createSingleLoopExtractorPass();
169
170 /// createBlockExtractorPass - This pass extracts all blocks (except those
171 /// specified in the argument list) from the functions in the module.
172 ///
173 ModulePass *createBlockExtractorPass();
174
175 /// createStripDeadPrototypesPass - This pass removes any function declarations
176 /// (prototypes) that are not used.
177 ModulePass *createStripDeadPrototypesPass();
178
179 //===----------------------------------------------------------------------===//
180 /// createFunctionAttrsPass - This pass discovers functions that do not access
181 /// memory, or only read memory, and gives them the readnone/readonly attribute.
182 /// It also discovers function arguments that are not captured by the function
183 /// and marks them with the nocapture attribute.
184 ///
185 Pass *createFunctionAttrsPass();
186
187 //===----------------------------------------------------------------------===//
188 /// createMergeFunctionsPass - This pass discovers identical functions and
189 /// collapses them.
190 ///
191 ModulePass *createMergeFunctionsPass();
192
193 //===----------------------------------------------------------------------===//
194 /// createPartialInliningPass - This pass inlines parts of functions.
195 ///
196 ModulePass *createPartialInliningPass();
197
198 //===----------------------------------------------------------------------===//
199 // createMetaRenamerPass - Rename everything with metasyntatic names.
200 //
201 ModulePass *createMetaRenamerPass();
202
203 //===----------------------------------------------------------------------===//
204 /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
205 /// manager.
206 ModulePass *createBarrierNoopPass();
207
208 /// \brief This pass lowers bitset metadata and the llvm.bitset.test intrinsic
209 /// to bitsets.
210 ModulePass *createLowerBitSetsPass();
211
212 } // End llvm namespace
213
214 #endif