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