Land the long talked about "type system rewrite" patch. This
[llvm/stm8.git] / include / llvm / Transforms / IPO.h
blobf025e180678bb95cf0d910a2739fd23a32e8d759
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.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TRANSFORMS_IPO_H
16 #define LLVM_TRANSFORMS_IPO_H
18 #include <vector>
20 namespace llvm {
22 class ModulePass;
23 class Pass;
24 class Function;
25 class BasicBlock;
26 class GlobalValue;
28 //===----------------------------------------------------------------------===//
30 // These functions removes symbols from functions and modules. If OnlyDebugInfo
31 // is true, only debugging information is removed from the module.
33 ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
35 //===----------------------------------------------------------------------===//
37 // These functions strips symbols from functions and modules.
38 // Only debugging information is not stripped.
40 ModulePass *createStripNonDebugSymbolsPass();
42 //===----------------------------------------------------------------------===//
44 // These pass removes llvm.dbg.declare intrinsics.
45 ModulePass *createStripDebugDeclarePass();
47 //===----------------------------------------------------------------------===//
49 // These pass removes unused symbols' debug info.
50 ModulePass *createStripDeadDebugInfoPass();
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();
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();
69 //===----------------------------------------------------------------------===//
70 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
71 /// non-address taken internal globals.
72 ///
73 ModulePass *createGlobalOptimizerPass();
76 //===----------------------------------------------------------------------===//
77 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
78 /// internal globals (functions or global variables)
79 ///
80 ModulePass *createGlobalDCEPass();
83 //===----------------------------------------------------------------------===//
84 /// createGVExtractionPass - If deleteFn is true, this pass deletes as
85 /// the specified global values. Otherwise, it deletes as much of the module as
86 /// possible, except for the global values specified.
87 ///
88 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
89 deleteFn = false);
91 //===----------------------------------------------------------------------===//
92 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
93 /// to inline direct function calls to small functions.
94 ///
95 /// The -inline-threshold command line option takes precedence over the
96 /// threshold given here.
97 Pass *createFunctionInliningPass();
98 Pass *createFunctionInliningPass(int Threshold);
100 //===----------------------------------------------------------------------===//
101 /// createAlwaysInlinerPass - Return a new pass object that inlines only
102 /// functions that are marked as "always_inline".
103 Pass *createAlwaysInlinerPass();
105 //===----------------------------------------------------------------------===//
106 /// createPruneEHPass - Return a new pass object which transforms invoke
107 /// instructions into calls, if the callee can _not_ unwind the stack.
109 Pass *createPruneEHPass();
111 //===----------------------------------------------------------------------===//
112 /// createInternalizePass - This pass loops over all of the functions in the
113 /// input module, internalizing all globals (functions and variables) not part
114 /// of the api. If a list of symbols is specified with the
115 /// -internalize-public-api-* command line options, those symbols are not
116 /// internalized and all others are. Otherwise if AllButMain is set and the
117 /// main function is found, all other globals are marked as internal. If no api
118 /// is supplied and AllButMain is not set, or no main function is found, nothing
119 /// is internalized.
121 ModulePass *createInternalizePass(bool AllButMain);
123 /// createInternalizePass - This pass loops over all of the functions in the
124 /// input module, internalizing all globals (functions and variables) not in the
125 /// given exportList.
127 /// Note that commandline options that are used with the above function are not
128 /// used now! Also, when exportList is empty, nothing is internalized.
129 ModulePass *createInternalizePass(const std::vector<const char *> &exportList);
131 //===----------------------------------------------------------------------===//
132 /// createDeadArgEliminationPass - This pass removes arguments from functions
133 /// which are not used by the body of the function.
135 ModulePass *createDeadArgEliminationPass();
137 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
138 /// functions as well. This is definitely not safe, and should only be used by
139 /// bugpoint.
140 ModulePass *createDeadArgHackingPass();
142 //===----------------------------------------------------------------------===//
143 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
144 /// be passed by value if the number of elements passed is smaller or
145 /// equal to maxElements (maxElements == 0 means always promote).
147 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
149 //===----------------------------------------------------------------------===//
150 /// createIPConstantPropagationPass - This pass propagates constants from call
151 /// sites into the bodies of functions.
153 ModulePass *createIPConstantPropagationPass();
155 //===----------------------------------------------------------------------===//
156 /// createIPSCCPPass - This pass propagates constants from call sites into the
157 /// bodies of functions, and keeps track of whether basic blocks are executable
158 /// in the process.
160 ModulePass *createIPSCCPPass();
162 //===----------------------------------------------------------------------===//
164 /// createLoopExtractorPass - This pass extracts all natural loops from the
165 /// program into a function if it can.
167 Pass *createLoopExtractorPass();
169 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
170 /// program into a function if it can. This is used by bugpoint.
172 Pass *createSingleLoopExtractorPass();
174 /// createBlockExtractorPass - This pass extracts all blocks (except those
175 /// specified in the argument list) from the functions in the module.
177 ModulePass *createBlockExtractorPass();
179 /// createStripDeadPrototypesPass - This pass removes any function declarations
180 /// (prototypes) that are not used.
181 ModulePass *createStripDeadPrototypesPass();
183 //===----------------------------------------------------------------------===//
184 /// createFunctionAttrsPass - This pass discovers functions that do not access
185 /// memory, or only read memory, and gives them the readnone/readonly attribute.
186 /// It also discovers function arguments that are not captured by the function
187 /// and marks them with the nocapture attribute.
189 Pass *createFunctionAttrsPass();
191 //===----------------------------------------------------------------------===//
192 /// createMergeFunctionsPass - This pass discovers identical functions and
193 /// collapses them.
195 ModulePass *createMergeFunctionsPass();
197 //===----------------------------------------------------------------------===//
198 /// createPartialInliningPass - This pass inlines parts of functions.
200 ModulePass *createPartialInliningPass();
202 } // End llvm namespace
204 #endif