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
25 class ModuleSummaryIndex;
33 //===----------------------------------------------------------------------===//
35 // These functions removes symbols from functions and modules. If OnlyDebugInfo
36 // is true, only debugging information is removed from the module.
38 ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
40 //===----------------------------------------------------------------------===//
42 // These functions strips symbols from functions and modules.
43 // Only debugging information is not stripped.
45 ModulePass *createStripNonDebugSymbolsPass();
47 /// This function returns a new pass that downgrades the debug info in the
48 /// module to line tables only.
49 ModulePass *createStripNonLineTableDebugInfoPass();
51 //===----------------------------------------------------------------------===//
53 // These pass removes llvm.dbg.declare intrinsics.
54 ModulePass *createStripDebugDeclarePass();
56 //===----------------------------------------------------------------------===//
58 // These pass removes unused symbols' debug info.
59 ModulePass *createStripDeadDebugInfoPass();
61 //===----------------------------------------------------------------------===//
62 /// createConstantMergePass - This function returns a new pass that merges
63 /// duplicate global constants together into a single constant that is shared.
64 /// This is useful because some passes (ie TraceValues) insert a lot of string
65 /// constants into the program, regardless of whether or not they duplicate an
68 ModulePass *createConstantMergePass();
70 //===----------------------------------------------------------------------===//
71 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
72 /// non-address taken internal globals.
74 ModulePass *createGlobalOptimizerPass();
76 //===----------------------------------------------------------------------===//
77 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
78 /// internal globals (functions or global variables)
80 ModulePass *createGlobalDCEPass();
82 //===----------------------------------------------------------------------===//
83 /// This transform is designed to eliminate available external globals
84 /// (functions or global variables)
86 ModulePass *createEliminateAvailableExternallyPass();
88 //===----------------------------------------------------------------------===//
89 /// createGVExtractionPass - If deleteFn is true, this pass deletes
90 /// the specified global values. Otherwise, it deletes as much of the module as
91 /// possible, except for the global values specified.
93 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
96 //===----------------------------------------------------------------------===//
97 /// This pass performs iterative function importing from other modules.
98 Pass *createFunctionImportPass();
100 //===----------------------------------------------------------------------===//
101 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
102 /// to inline direct function calls to small functions.
104 /// The Threshold can be passed directly, or asked to be computed from the
105 /// given optimization and size optimization arguments.
107 /// The -inline-threshold command line option takes precedence over the
108 /// threshold given here.
109 Pass *createFunctionInliningPass();
110 Pass *createFunctionInliningPass(int Threshold);
111 Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel);
112 Pass *createFunctionInliningPass(InlineParams &Params);
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) it can.
124 /// Before internalizing a symbol, the callback \p MustPreserveGV is invoked and
125 /// gives to the client the ability to prevent internalizing specific symbols.
127 /// The symbol in DSOList are internalized if it is safe to drop them from
128 /// the symbol table.
130 /// Note that commandline options that are used with the above function are not
133 createInternalizePass(std::function<bool(const GlobalValue &)> MustPreserveGV);
135 /// createInternalizePass - Same as above, but with an empty exportList.
136 ModulePass *createInternalizePass();
138 //===----------------------------------------------------------------------===//
139 /// createDeadArgEliminationPass - This pass removes arguments from functions
140 /// which are not used by the body of the function.
142 ModulePass *createDeadArgEliminationPass();
144 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
145 /// functions as well. This is definitely not safe, and should only be used by
147 ModulePass *createDeadArgHackingPass();
149 //===----------------------------------------------------------------------===//
150 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
151 /// be passed by value if the number of elements passed is smaller or
152 /// equal to maxElements (maxElements == 0 means always promote).
154 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
156 //===----------------------------------------------------------------------===//
157 /// createIPConstantPropagationPass - This pass propagates constants from call
158 /// sites into the bodies of functions.
160 ModulePass *createIPConstantPropagationPass();
162 //===----------------------------------------------------------------------===//
163 /// createIPSCCPPass - This pass propagates constants from call sites into the
164 /// bodies of functions, and keeps track of whether basic blocks are executable
167 ModulePass *createIPSCCPPass();
169 //===----------------------------------------------------------------------===//
171 /// createLoopExtractorPass - This pass extracts all natural loops from the
172 /// program into a function if it can.
174 Pass *createLoopExtractorPass();
176 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
177 /// program into a function if it can. This is used by bugpoint.
179 Pass *createSingleLoopExtractorPass();
181 /// createBlockExtractorPass - This pass extracts all blocks (except those
182 /// specified in the argument list) from the functions in the module.
184 ModulePass *createBlockExtractorPass();
186 /// createStripDeadPrototypesPass - This pass removes any function declarations
187 /// (prototypes) that are not used.
188 ModulePass *createStripDeadPrototypesPass();
190 //===----------------------------------------------------------------------===//
191 /// createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call
192 /// graph in RPO to deduce and propagate function attributes. Currently it
193 /// only handles synthesizing norecurse attributes.
195 Pass *createReversePostOrderFunctionAttrsPass();
197 //===----------------------------------------------------------------------===//
198 /// createMergeFunctionsPass - This pass discovers identical functions and
201 ModulePass *createMergeFunctionsPass();
203 //===----------------------------------------------------------------------===//
204 /// createPartialInliningPass - This pass inlines parts of functions.
206 ModulePass *createPartialInliningPass();
208 //===----------------------------------------------------------------------===//
209 // createMetaRenamerPass - Rename everything with metasyntatic names.
211 ModulePass *createMetaRenamerPass();
213 //===----------------------------------------------------------------------===//
214 /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
216 ModulePass *createBarrierNoopPass();
218 /// \brief This pass lowers type metadata and the llvm.type.test intrinsic to
220 ModulePass *createLowerTypeTestsPass();
222 /// \brief This pass export CFI checks for use by external modules.
223 ModulePass *createCrossDSOCFIPass();
225 /// \brief This pass implements whole-program devirtualization using type
227 ModulePass *createWholeProgramDevirtPass();
229 /// This pass splits globals into pieces for the benefit of whole-program
230 /// devirtualization and control-flow integrity.
231 ModulePass *createGlobalSplitPass();
233 //===----------------------------------------------------------------------===//
234 // SampleProfilePass - Loads sample profile data from disk and generates
235 // IR metadata to reflect the profile.
236 ModulePass *createSampleProfileLoaderPass();
237 ModulePass *createSampleProfileLoaderPass(StringRef Name);
239 /// Write ThinLTO-ready bitcode to Str.
240 ModulePass *createWriteThinLTOBitcodePass(raw_ostream &Str);
242 } // End llvm namespace