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
29 //===----------------------------------------------------------------------===//
31 // These functions removes symbols from functions and modules. If OnlyDebugInfo
32 // is true, only debugging information is removed from the module.
34 ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
36 //===----------------------------------------------------------------------===//
38 // These functions strips symbols from functions and modules.
39 // Only debugging information is not stripped.
41 ModulePass *createStripNonDebugSymbolsPass();
43 //===----------------------------------------------------------------------===//
45 // These pass removes llvm.dbg.declare intrinsics.
46 ModulePass *createStripDebugDeclarePass();
48 //===----------------------------------------------------------------------===//
49 /// createLowerSetJmpPass - This function lowers the setjmp/longjmp intrinsics
50 /// to invoke/unwind instructions. This should really be part of the C/C++
51 /// front-end, but it's so much easier to write transformations in LLVM proper.
53 ModulePass *createLowerSetJmpPass();
55 //===----------------------------------------------------------------------===//
56 /// createConstantMergePass - This function returns a new pass that merges
57 /// duplicate global constants together into a single constant that is shared.
58 /// This is useful because some passes (ie TraceValues) insert a lot of string
59 /// constants into the program, regardless of whether or not they duplicate an
62 ModulePass *createConstantMergePass();
65 //===----------------------------------------------------------------------===//
66 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
67 /// non-address taken internal globals.
69 ModulePass *createGlobalOptimizerPass();
72 //===----------------------------------------------------------------------===//
73 /// createRaiseAllocationsPass - Return a new pass that transforms malloc and
74 /// free function calls into malloc and free instructions.
76 ModulePass *createRaiseAllocationsPass();
79 //===----------------------------------------------------------------------===//
80 /// createDeadTypeEliminationPass - Return a new pass that eliminates symbol
81 /// table entries for types that are never used.
83 ModulePass *createDeadTypeEliminationPass();
86 //===----------------------------------------------------------------------===//
87 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
88 /// internal globals (functions or global variables)
90 ModulePass *createGlobalDCEPass();
93 //===----------------------------------------------------------------------===//
94 /// createGVExtractionPass - If deleteFn is true, this pass deletes as
95 /// the specified global values. Otherwise, it deletes as much of the module as
96 /// possible, except for the global values specified.
98 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
100 bool relinkCallees = false);
102 //===----------------------------------------------------------------------===//
103 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
104 /// to inline direct function calls to small functions.
106 Pass *createFunctionInliningPass();
107 Pass *createFunctionInliningPass(int Threshold);
109 //===----------------------------------------------------------------------===//
110 /// createAlwaysInlinerPass - Return a new pass object that inlines only
111 /// functions that are marked as "always_inline".
112 Pass *createAlwaysInlinerPass();
114 //===----------------------------------------------------------------------===//
115 /// createPruneEHPass - Return a new pass object which transforms invoke
116 /// instructions into calls, if the callee can _not_ unwind the stack.
118 Pass *createPruneEHPass();
120 //===----------------------------------------------------------------------===//
121 /// createInternalizePass - This pass loops over all of the functions in the
122 /// input module, internalizing all globals (functions and variables) not part
123 /// of the api. If a list of symbols is specified with the
124 /// -internalize-public-api-* command line options, those symbols are not
125 /// internalized and all others are. Otherwise if AllButMain is set and the
126 /// main function is found, all other globals are marked as internal. If no api
127 /// is supplied and AllButMain is not set, or no main function is found, nothing
130 ModulePass *createInternalizePass(bool AllButMain);
132 /// createInternalizePass - This pass loops over all of the functions in the
133 /// input module, internalizing all globals (functions and variables) not in the
134 /// given exportList.
136 /// Note that commandline options that are used with the above function are not
137 /// used now! Also, when exportList is empty, nothing is internalized.
138 ModulePass *createInternalizePass(const std::vector<const char *> &exportList);
140 //===----------------------------------------------------------------------===//
141 /// createDeadArgEliminationPass - This pass removes arguments from functions
142 /// which are not used by the body of the function.
144 ModulePass *createDeadArgEliminationPass();
146 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
147 /// functions as well. This is definitely not safe, and should only be used by
149 ModulePass *createDeadArgHackingPass();
151 //===----------------------------------------------------------------------===//
152 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
153 /// be passed by value if the number of elements passed is smaller or
154 /// equal to maxElements (maxElements == 0 means always promote).
156 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
157 Pass *createStructRetPromotionPass();
159 //===----------------------------------------------------------------------===//
160 /// createIPConstantPropagationPass - This pass propagates constants from call
161 /// sites into the bodies of functions.
163 ModulePass *createIPConstantPropagationPass();
165 //===----------------------------------------------------------------------===//
166 /// createIPSCCPPass - This pass propagates constants from call sites into the
167 /// bodies of functions, and keeps track of whether basic blocks are executable
170 ModulePass *createIPSCCPPass();
172 //===----------------------------------------------------------------------===//
174 /// createLoopExtractorPass - This pass extracts all natural loops from the
175 /// program into a function if it can.
177 FunctionPass *createLoopExtractorPass();
179 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
180 /// program into a function if it can. This is used by bugpoint.
182 FunctionPass *createSingleLoopExtractorPass();
184 /// createBlockExtractorPass - This pass extracts all blocks (except those
185 /// specified in the argument list) from the functions in the module.
187 ModulePass *createBlockExtractorPass(const std::vector<BasicBlock*> &BTNE);
189 /// createIndMemRemPass - This pass removes potential indirect calls of
191 ModulePass *createIndMemRemPass();
193 /// createStripDeadPrototypesPass - This pass removes any function declarations
194 /// (prototypes) that are not used.
195 ModulePass *createStripDeadPrototypesPass();
197 //===----------------------------------------------------------------------===//
198 /// createPartialSpecializationPass - This pass specializes functions for
199 /// constant arguments.
201 ModulePass *createPartialSpecializationPass();
203 //===----------------------------------------------------------------------===//
204 /// createFunctionAttrsPass - This pass discovers functions that do not access
205 /// memory, or only read memory, and gives them the readnone/readonly attribute.
206 /// It also discovers function arguments that are not captured by the function
207 /// and marks them with the nocapture attribute.
209 Pass *createFunctionAttrsPass();
211 //===----------------------------------------------------------------------===//
212 /// createMergeFunctionsPass - This pass discovers identical functions and
215 ModulePass *createMergeFunctionsPass();
217 //===----------------------------------------------------------------------===//
218 /// createPartialInliningPass - This pass inlines parts of functions.
220 ModulePass *createPartialInliningPass();
222 } // End llvm namespace