IPO.h revision 579a0246616d76bc536de0e41edf069d091604be
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
20namespace llvm {
21
22class FunctionPass;
23class ModulePass;
24class Pass;
25class Function;
26class BasicBlock;
27class 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//
34ModulePass *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///
41ModulePass *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///
50ModulePass *createConstantMergePass();
51
52
53//===----------------------------------------------------------------------===//
54/// createGlobalOptimizerPass - This function returns a new pass that optimizes
55/// non-address taken internal globals.
56///
57ModulePass *createGlobalOptimizerPass();
58
59
60//===----------------------------------------------------------------------===//
61/// createRaiseAllocationsPass - Return a new pass that transforms malloc and
62/// free function calls into malloc and free instructions.
63///
64ModulePass *createRaiseAllocationsPass();
65
66
67//===----------------------------------------------------------------------===//
68/// createDeadTypeEliminationPass - Return a new pass that eliminates symbol
69/// table entries for types that are never used.
70///
71ModulePass *createDeadTypeEliminationPass();
72
73
74//===----------------------------------------------------------------------===//
75/// createGlobalDCEPass - This transform is designed to eliminate unreachable
76/// internal globals (functions or global variables)
77///
78ModulePass *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///
86ModulePass *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///
94Pass *createFunctionInliningPass();
95Pass *createFunctionInliningPass(int Threshold);
96
97//===----------------------------------------------------------------------===//
98/// createAlwaysInlinerPass - Return a new pass object that inlines only
99/// functions that are marked as "always_inline".
100Pass *createAlwaysInlinerPass();
101
102//===----------------------------------------------------------------------===//
103/// createPruneEHPass - Return a new pass object which transforms invoke
104/// instructions into calls, if the callee can _not_ unwind the stack.
105///
106Pass *createPruneEHPass();
107
108//===----------------------------------------------------------------------===//
109/// createInternalizePass - This pass loops over all of the functions in the
110/// input module, internalizing all globals (functions and variables) not part
111/// of the api.  If a list of symbols is specified with the
112/// -internalize-public-api-* command line options, those symbols are not
113/// internalized and all others are.  Otherwise if AllButMain is set and the
114/// main function is found, all other globals are marked as internal. If no api
115/// is supplied and AllButMain is not set, or no main function is found, nothing
116/// is internalized.
117///
118ModulePass *createInternalizePass(bool AllButMain);
119
120/// createInternalizePass - This pass loops over all of the functions in the
121/// input module, internalizing all globals (functions and variables) not in the
122/// given exportList.
123///
124/// Note that commandline options that are used with the above function are not
125/// used now! Also, when exportList is empty, nothing is internalized.
126ModulePass *createInternalizePass(const std::vector<const char *> &exportList);
127
128//===----------------------------------------------------------------------===//
129/// createDeadArgEliminationPass - This pass removes arguments from functions
130/// which are not used by the body of the function.
131///
132ModulePass *createDeadArgEliminationPass();
133
134/// DeadArgHacking pass - Same as DAE, but delete arguments of external
135/// functions as well.  This is definitely not safe, and should only be used by
136/// bugpoint.
137ModulePass *createDeadArgHackingPass();
138
139//===----------------------------------------------------------------------===//
140/// createArgumentPromotionPass - This pass promotes "by reference" arguments to
141/// be passed by value if the number of elements passed is smaller or
142/// equal to maxElements (maxElements == 0 means always promote).
143///
144Pass *createArgumentPromotionPass(unsigned maxElements = 3);
145Pass *createStructRetPromotionPass();
146
147//===----------------------------------------------------------------------===//
148/// createIPConstantPropagationPass - This pass propagates constants from call
149/// sites into the bodies of functions.
150///
151ModulePass *createIPConstantPropagationPass();
152
153//===----------------------------------------------------------------------===//
154/// createIPSCCPPass - This pass propagates constants from call sites into the
155/// bodies of functions, and keeps track of whether basic blocks are executable
156/// in the process.
157///
158ModulePass *createIPSCCPPass();
159
160//===----------------------------------------------------------------------===//
161//
162/// createLoopExtractorPass - This pass extracts all natural loops from the
163/// program into a function if it can.
164///
165FunctionPass *createLoopExtractorPass();
166
167/// createSingleLoopExtractorPass - This pass extracts one natural loop from the
168/// program into a function if it can.  This is used by bugpoint.
169///
170FunctionPass *createSingleLoopExtractorPass();
171
172/// createBlockExtractorPass - This pass extracts all blocks (except those
173/// specified in the argument list) from the functions in the module.
174///
175ModulePass *createBlockExtractorPass(const std::vector<BasicBlock*> &BTNE);
176
177/// createIndMemRemPass - This pass removes potential indirect calls of
178/// malloc and free
179ModulePass *createIndMemRemPass();
180
181/// createStripDeadPrototypesPass - This pass removes any function declarations
182/// (prototypes) that are not used.
183ModulePass *createStripDeadPrototypesPass();
184
185//===----------------------------------------------------------------------===//
186/// createPartialSpecializationPass - This pass specializes functions for
187/// constant arguments.
188///
189ModulePass *createPartialSpecializationPass();
190
191//===----------------------------------------------------------------------===//
192/// createAddReadAttrsPass - This pass discovers functions that do not access
193/// memory, or only read memory, and gives them the readnone/readonly attribute.
194///
195Pass *createAddReadAttrsPass();
196
197//===----------------------------------------------------------------------===//
198/// createMergeFunctionsPass - This pass discovers identical functions and
199/// collapses them.
200///
201ModulePass *createMergeFunctionsPass();
202
203} // End llvm namespace
204
205#endif
206