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
18 #include "llvm/ADT/ArrayRef.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 /// createConstantMergePass - This function returns a new pass that merges
54 /// duplicate global constants together into a single constant that is shared.
55 /// This is useful because some passes (ie TraceValues) insert a lot of string
56 /// constants into the program, regardless of whether or not they duplicate an
59 ModulePass *createConstantMergePass();
61 //===----------------------------------------------------------------------===//
62 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
63 /// non-address taken internal globals.
65 ModulePass *createGlobalOptimizerPass();
67 //===----------------------------------------------------------------------===//
68 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
69 /// internal globals (functions or global variables)
71 ModulePass *createGlobalDCEPass();
73 //===----------------------------------------------------------------------===//
74 /// This transform is designed to eliminate available external globals
75 /// (functions or global variables)
77 ModulePass *createEliminateAvailableExternallyPass();
79 //===----------------------------------------------------------------------===//
80 /// createGVExtractionPass - If deleteFn is true, this pass deletes
81 /// the specified global values. Otherwise, it deletes as much of the module as
82 /// possible, except for the global values specified.
84 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
87 //===----------------------------------------------------------------------===//
88 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
89 /// to inline direct function calls to small functions.
91 /// The Threshold can be passed directly, or asked to be computed from the
92 /// given optimization and size optimization arguments.
94 /// The -inline-threshold command line option takes precedence over the
95 /// threshold given here.
96 Pass *createFunctionInliningPass();
97 Pass *createFunctionInliningPass(int Threshold);
98 Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel);
100 //===----------------------------------------------------------------------===//
101 /// createAlwaysInlinerPass - Return a new pass object that inlines only
102 /// functions that are marked as "always_inline".
103 Pass *createAlwaysInlinerPass();
104 Pass *createAlwaysInlinerPass(bool InsertLifetime);
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) it can.
116 /// The symbols in \p ExportList are never internalized.
118 /// The symbol in DSOList are internalized if it is safe to drop them from
119 /// the symbol table.
121 /// Note that commandline options that are used with the above function are not
123 ModulePass *createInternalizePass(ArrayRef<const char *> ExportList);
124 /// createInternalizePass - Same as above, but with an empty exportList.
125 ModulePass *createInternalizePass();
127 //===----------------------------------------------------------------------===//
128 /// createDeadArgEliminationPass - This pass removes arguments from functions
129 /// which are not used by the body of the function.
131 ModulePass *createDeadArgEliminationPass();
133 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
134 /// functions as well. This is definitely not safe, and should only be used by
136 ModulePass *createDeadArgHackingPass();
138 //===----------------------------------------------------------------------===//
139 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
140 /// be passed by value if the number of elements passed is smaller or
141 /// equal to maxElements (maxElements == 0 means always promote).
143 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
145 //===----------------------------------------------------------------------===//
146 /// createIPConstantPropagationPass - This pass propagates constants from call
147 /// sites into the bodies of functions.
149 ModulePass *createIPConstantPropagationPass();
151 //===----------------------------------------------------------------------===//
152 /// createIPSCCPPass - This pass propagates constants from call sites into the
153 /// bodies of functions, and keeps track of whether basic blocks are executable
156 ModulePass *createIPSCCPPass();
158 //===----------------------------------------------------------------------===//
160 /// createLoopExtractorPass - This pass extracts all natural loops from the
161 /// program into a function if it can.
163 Pass *createLoopExtractorPass();
165 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
166 /// program into a function if it can. This is used by bugpoint.
168 Pass *createSingleLoopExtractorPass();
170 /// createBlockExtractorPass - This pass extracts all blocks (except those
171 /// specified in the argument list) from the functions in the module.
173 ModulePass *createBlockExtractorPass();
175 /// createStripDeadPrototypesPass - This pass removes any function declarations
176 /// (prototypes) that are not used.
177 ModulePass *createStripDeadPrototypesPass();
179 //===----------------------------------------------------------------------===//
180 /// createFunctionAttrsPass - This pass discovers functions that do not access
181 /// memory, or only read memory, and gives them the readnone/readonly attribute.
182 /// It also discovers function arguments that are not captured by the function
183 /// and marks them with the nocapture attribute.
185 Pass *createFunctionAttrsPass();
187 //===----------------------------------------------------------------------===//
188 /// createMergeFunctionsPass - This pass discovers identical functions and
191 ModulePass *createMergeFunctionsPass();
193 //===----------------------------------------------------------------------===//
194 /// createPartialInliningPass - This pass inlines parts of functions.
196 ModulePass *createPartialInliningPass();
198 //===----------------------------------------------------------------------===//
199 // createMetaRenamerPass - Rename everything with metasyntatic names.
201 ModulePass *createMetaRenamerPass();
203 //===----------------------------------------------------------------------===//
204 /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
206 ModulePass *createBarrierNoopPass();
208 /// \brief This pass lowers bitset metadata and the llvm.bitset.test intrinsic
210 ModulePass *createLowerBitSetsPass();
212 } // End llvm namespace