1 //===- llvm/Transforms/IPO.h - Interprocedural Transformations --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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
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.
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
66 ModulePass *createConstantMergePass();
69 //===----------------------------------------------------------------------===//
70 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
71 /// non-address taken internal globals.
73 ModulePass *createGlobalOptimizerPass();
76 //===----------------------------------------------------------------------===//
77 /// createDeadTypeEliminationPass - Return a new pass that eliminates symbol
78 /// table entries for types that are never used.
80 ModulePass *createDeadTypeEliminationPass();
83 //===----------------------------------------------------------------------===//
84 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
85 /// internal globals (functions or global variables)
87 ModulePass *createGlobalDCEPass();
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.
95 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
98 //===----------------------------------------------------------------------===//
99 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
100 /// to inline direct function calls to small functions.
102 Pass *createFunctionInliningPass();
103 Pass *createFunctionInliningPass(int Threshold);
105 //===----------------------------------------------------------------------===//
106 /// createAlwaysInlinerPass - Return a new pass object that inlines only
107 /// functions that are marked as "always_inline".
108 Pass *createAlwaysInlinerPass();
110 //===----------------------------------------------------------------------===//
111 /// createPruneEHPass - Return a new pass object which transforms invoke
112 /// instructions into calls, if the callee can _not_ unwind the stack.
114 Pass *createPruneEHPass();
116 //===----------------------------------------------------------------------===//
117 /// createInternalizePass - This pass loops over all of the functions in the
118 /// input module, internalizing all globals (functions and variables) not part
119 /// of the api. If a list of symbols is specified with the
120 /// -internalize-public-api-* command line options, those symbols are not
121 /// internalized and all others are. Otherwise if AllButMain is set and the
122 /// main function is found, all other globals are marked as internal. If no api
123 /// is supplied and AllButMain is not set, or no main function is found, nothing
126 ModulePass *createInternalizePass(bool AllButMain);
128 /// createInternalizePass - This pass loops over all of the functions in the
129 /// input module, internalizing all globals (functions and variables) not in the
130 /// given exportList.
132 /// Note that commandline options that are used with the above function are not
133 /// used now! Also, when exportList is empty, nothing is internalized.
134 ModulePass *createInternalizePass(const std::vector<const char *> &exportList);
136 //===----------------------------------------------------------------------===//
137 /// createDeadArgEliminationPass - This pass removes arguments from functions
138 /// which are not used by the body of the function.
140 ModulePass *createDeadArgEliminationPass();
142 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
143 /// functions as well. This is definitely not safe, and should only be used by
145 ModulePass *createDeadArgHackingPass();
147 //===----------------------------------------------------------------------===//
148 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
149 /// be passed by value if the number of elements passed is smaller or
150 /// equal to maxElements (maxElements == 0 means always promote).
152 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
153 Pass *createStructRetPromotionPass();
155 //===----------------------------------------------------------------------===//
156 /// createIPConstantPropagationPass - This pass propagates constants from call
157 /// sites into the bodies of functions.
159 ModulePass *createIPConstantPropagationPass();
161 //===----------------------------------------------------------------------===//
162 /// createIPSCCPPass - This pass propagates constants from call sites into the
163 /// bodies of functions, and keeps track of whether basic blocks are executable
166 ModulePass *createIPSCCPPass();
168 //===----------------------------------------------------------------------===//
170 /// createLoopExtractorPass - This pass extracts all natural loops from the
171 /// program into a function if it can.
173 Pass *createLoopExtractorPass();
175 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
176 /// program into a function if it can. This is used by bugpoint.
178 Pass *createSingleLoopExtractorPass();
180 /// createBlockExtractorPass - This pass extracts all blocks (except those
181 /// specified in the argument list) from the functions in the module.
183 ModulePass *createBlockExtractorPass();
185 /// createStripDeadPrototypesPass - This pass removes any function declarations
186 /// (prototypes) that are not used.
187 ModulePass *createStripDeadPrototypesPass();
189 //===----------------------------------------------------------------------===//
190 /// createPartialSpecializationPass - This pass specializes functions for
191 /// constant arguments.
193 ModulePass *createPartialSpecializationPass();
195 //===----------------------------------------------------------------------===//
196 /// createFunctionAttrsPass - This pass discovers functions that do not access
197 /// memory, or only read memory, and gives them the readnone/readonly attribute.
198 /// It also discovers function arguments that are not captured by the function
199 /// and marks them with the nocapture attribute.
201 Pass *createFunctionAttrsPass();
203 //===----------------------------------------------------------------------===//
204 /// createMergeFunctionsPass - This pass discovers identical functions and
207 ModulePass *createMergeFunctionsPass();
209 //===----------------------------------------------------------------------===//
210 /// createPartialInliningPass - This pass inlines parts of functions.
212 ModulePass *createPartialInliningPass();
214 } // End llvm namespace