Propagate changes from my local tree. This patch includes:
[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 was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source 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
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 /// createLowerSetJmpPass - This function lowers the setjmp/longjmp intrinsics
37 /// to invoke/unwind instructions.  This should really be part of the C/C++
38 /// front-end, but it's so much easier to write transformations in LLVM proper.
39 ///
40 ModulePass* createLowerSetJmpPass();
41
42 //===----------------------------------------------------------------------===//
43 /// createConstantMergePass - This function returns a new pass that merges
44 /// duplicate global constants together into a single constant that is shared.
45 /// This is useful because some passes (ie TraceValues) insert a lot of string
46 /// constants into the program, regardless of whether or not they duplicate an
47 /// existing string.
48 ///
49 ModulePass *createConstantMergePass();
50
51
52 //===----------------------------------------------------------------------===//
53 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
54 /// non-address taken internal globals.
55 ///
56 ModulePass *createGlobalOptimizerPass();
57
58
59 //===----------------------------------------------------------------------===//
60 /// createRaiseAllocationsPass - Return a new pass that transforms malloc and
61 /// free function calls into malloc and free instructions.
62 ///
63 ModulePass *createRaiseAllocationsPass();
64
65
66 //===----------------------------------------------------------------------===//
67 /// createDeadTypeEliminationPass - Return a new pass that eliminates symbol
68 /// table entries for types that are never used.
69 ///
70 ModulePass *createDeadTypeEliminationPass();
71
72
73 //===----------------------------------------------------------------------===//
74 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
75 /// internal globals (functions or global variables)
76 ///
77 ModulePass *createGlobalDCEPass();
78
79
80 //===----------------------------------------------------------------------===//
81 /// createFunctionExtractionPass - If deleteFn is true, this pass deletes as
82 /// the specified function. Otherwise, it deletes as much of the module as
83 /// possible, except for the function specified.
84 ///
85 ModulePass *createFunctionExtractionPass(Function *F, bool deleteFn = false,
86                                          bool relinkCallees = false);
87
88
89 //===----------------------------------------------------------------------===//
90 /// FunctionResolvingPass - Go over the functions that are in the module and
91 /// look for functions that have the same name.  More often than not, there will
92 /// be things like:
93 ///    void "foo"(...)
94 ///    void "foo"(int, int)
95 /// because of the way things are declared in C.  If this is the case, patch
96 /// things up.
97 ///
98 /// This is an interprocedural pass.
99 ///
100 ModulePass *createFunctionResolvingPass();
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
108 //===----------------------------------------------------------------------===//
109 /// createPruneEHPass - Return a new pass object which transforms invoke
110 /// instructions into calls, if the callee can _not_ unwind the stack.
111 ///
112 Pass *createPruneEHPass();
113
114 //===----------------------------------------------------------------------===//
115 /// createInternalizePass - This pass loops over all of the functions in the
116 /// input module, looking for a main function.  If a list of symbols is
117 /// specified with the -internalize-public-api-* command line options, those
118 /// symbols are internalized.  Otherwise if InternalizeEverything is set and
119 /// the main function is found, all other globals are marked as internal.
120 ///
121 ModulePass *createInternalizePass(bool InternalizeEverything);
122 ModulePass *createInternalizePass(const std::vector<const char *> &exportList);
123
124 //===----------------------------------------------------------------------===//
125 /// createDeadArgEliminationPass - This pass removes arguments from functions
126 /// which are not used by the body of the function.
127 ///
128 ModulePass *createDeadArgEliminationPass();
129
130 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
131 /// functions as well.  This is definitely not safe, and should only be used by
132 /// bugpoint.
133 ModulePass *createDeadArgHackingPass();
134
135 //===----------------------------------------------------------------------===//
136 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
137 /// be passed by value.
138 ///
139 Pass *createArgumentPromotionPass();
140
141 //===----------------------------------------------------------------------===//
142 /// createIPConstantPropagationPass - This pass propagates constants from call
143 /// sites into the bodies of functions.
144 ///
145 ModulePass *createIPConstantPropagationPass();
146
147 //===----------------------------------------------------------------------===//
148 /// createIPSCCPPass - This pass propagates constants from call sites into the
149 /// bodies of functions, and keeps track of whether basic blocks are executable
150 /// in the process.
151 ///
152 ModulePass *createIPSCCPPass();
153
154 //===----------------------------------------------------------------------===//
155 //
156 /// createLoopExtractorPass - This pass extracts all natural loops from the
157 /// program into a function if it can.
158 ///
159 FunctionPass *createLoopExtractorPass();
160
161 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
162 /// program into a function if it can.  This is used by bugpoint.
163 ///
164 FunctionPass *createSingleLoopExtractorPass();
165
166 // createBlockExtractorPass - This pass extracts all blocks (except those
167 // specified in the argument list) from the functions in the module.
168 //
169 ModulePass *createBlockExtractorPass(std::vector<BasicBlock*> &BTNE);
170
171 // createOptimizeWellKnownCallsPass - This pass optimizes specific calls to
172 // specific well-known (library) functions.
173 ModulePass *createSimplifyLibCallsPass();
174
175
176 // createIndMemRemPass - This pass removes potential indirect calls of
177 // malloc and free
178 ModulePass *createIndMemRemPass();
179
180 } // End llvm namespace
181
182 #endif