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 //===----------------------------------------------------------------------===//
48 /// createLowerSetJmpPass - This function lowers the setjmp/longjmp intrinsics
49 /// to invoke/unwind instructions. This should really be part of the C/C++
50 /// front-end, but it's so much easier to write transformations in LLVM proper.
52 ModulePass *createLowerSetJmpPass();
54 //===----------------------------------------------------------------------===//
55 /// createConstantMergePass - This function returns a new pass that merges
56 /// duplicate global constants together into a single constant that is shared.
57 /// This is useful because some passes (ie TraceValues) insert a lot of string
58 /// constants into the program, regardless of whether or not they duplicate an
61 ModulePass *createConstantMergePass();
64 //===----------------------------------------------------------------------===//
65 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
66 /// non-address taken internal globals.
68 ModulePass *createGlobalOptimizerPass();
71 //===----------------------------------------------------------------------===//
72 /// createDeadTypeEliminationPass - Return a new pass that eliminates symbol
73 /// table entries for types that are never used.
75 ModulePass *createDeadTypeEliminationPass();
78 //===----------------------------------------------------------------------===//
79 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
80 /// internal globals (functions or global variables)
82 ModulePass *createGlobalDCEPass();
85 //===----------------------------------------------------------------------===//
86 /// createGVExtractionPass - If deleteFn is true, this pass deletes as
87 /// the specified global values. Otherwise, it deletes as much of the module as
88 /// possible, except for the global values specified.
90 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
92 bool relinkCallees = false);
94 //===----------------------------------------------------------------------===//
95 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
96 /// to inline direct function calls to small functions.
98 Pass *createFunctionInliningPass();
99 Pass *createFunctionInliningPass(int Threshold);
101 //===----------------------------------------------------------------------===//
102 /// createAlwaysInlinerPass - Return a new pass object that inlines only
103 /// functions that are marked as "always_inline".
104 Pass *createAlwaysInlinerPass();
106 //===----------------------------------------------------------------------===//
107 /// createPruneEHPass - Return a new pass object which transforms invoke
108 /// instructions into calls, if the callee can _not_ unwind the stack.
110 Pass *createPruneEHPass();
112 //===----------------------------------------------------------------------===//
113 /// createInternalizePass - This pass loops over all of the functions in the
114 /// input module, internalizing all globals (functions and variables) not part
115 /// of the api. If a list of symbols is specified with the
116 /// -internalize-public-api-* command line options, those symbols are not
117 /// internalized and all others are. Otherwise if AllButMain is set and the
118 /// main function is found, all other globals are marked as internal. If no api
119 /// is supplied and AllButMain is not set, or no main function is found, nothing
122 ModulePass *createInternalizePass(bool AllButMain);
124 /// createInternalizePass - This pass loops over all of the functions in the
125 /// input module, internalizing all globals (functions and variables) not in the
126 /// given exportList.
128 /// Note that commandline options that are used with the above function are not
129 /// used now! Also, when exportList is empty, nothing is internalized.
130 ModulePass *createInternalizePass(const std::vector<const char *> &exportList);
132 //===----------------------------------------------------------------------===//
133 /// createDeadArgEliminationPass - This pass removes arguments from functions
134 /// which are not used by the body of the function.
136 ModulePass *createDeadArgEliminationPass();
138 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
139 /// functions as well. This is definitely not safe, and should only be used by
141 ModulePass *createDeadArgHackingPass();
143 //===----------------------------------------------------------------------===//
144 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
145 /// be passed by value if the number of elements passed is smaller or
146 /// equal to maxElements (maxElements == 0 means always promote).
148 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
149 Pass *createStructRetPromotionPass();
151 //===----------------------------------------------------------------------===//
152 /// createIPConstantPropagationPass - This pass propagates constants from call
153 /// sites into the bodies of functions.
155 ModulePass *createIPConstantPropagationPass();
157 //===----------------------------------------------------------------------===//
158 /// createIPSCCPPass - This pass propagates constants from call sites into the
159 /// bodies of functions, and keeps track of whether basic blocks are executable
162 ModulePass *createIPSCCPPass();
164 //===----------------------------------------------------------------------===//
166 /// createLoopExtractorPass - This pass extracts all natural loops from the
167 /// program into a function if it can.
169 Pass *createLoopExtractorPass();
171 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
172 /// program into a function if it can. This is used by bugpoint.
174 Pass *createSingleLoopExtractorPass();
176 /// createBlockExtractorPass - This pass extracts all blocks (except those
177 /// specified in the argument list) from the functions in the module.
179 ModulePass *createBlockExtractorPass(const std::vector<BasicBlock*> &BTNE);
181 /// createStripDeadPrototypesPass - This pass removes any function declarations
182 /// (prototypes) that are not used.
183 ModulePass *createStripDeadPrototypesPass();
185 //===----------------------------------------------------------------------===//
186 /// createPartialSpecializationPass - This pass specializes functions for
187 /// constant arguments.
189 ModulePass *createPartialSpecializationPass();
191 //===----------------------------------------------------------------------===//
192 /// createFunctionAttrsPass - This pass discovers functions that do not access
193 /// memory, or only read memory, and gives them the readnone/readonly attribute.
194 /// It also discovers function arguments that are not captured by the function
195 /// and marks them with the nocapture attribute.
197 Pass *createFunctionAttrsPass();
199 //===----------------------------------------------------------------------===//
200 /// createMergeFunctionsPass - This pass discovers identical functions and
203 ModulePass *createMergeFunctionsPass();
205 //===----------------------------------------------------------------------===//
206 /// createPartialInliningPass - This pass inlines parts of functions.
208 ModulePass *createPartialInliningPass();
210 } // End llvm namespace