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
24 class ModuleSummaryIndex;
31 //===----------------------------------------------------------------------===//
33 // These functions removes symbols from functions and modules. If OnlyDebugInfo
34 // is true, only debugging information is removed from the module.
36 ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
38 //===----------------------------------------------------------------------===//
40 // These functions strips symbols from functions and modules.
41 // Only debugging information is not stripped.
43 ModulePass *createStripNonDebugSymbolsPass();
45 //===----------------------------------------------------------------------===//
47 // These pass removes llvm.dbg.declare intrinsics.
48 ModulePass *createStripDebugDeclarePass();
50 //===----------------------------------------------------------------------===//
52 // These pass removes unused symbols' debug info.
53 ModulePass *createStripDeadDebugInfoPass();
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();
64 //===----------------------------------------------------------------------===//
65 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
66 /// non-address taken internal globals.
68 ModulePass *createGlobalOptimizerPass();
70 //===----------------------------------------------------------------------===//
71 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
72 /// internal globals (functions or global variables)
74 ModulePass *createGlobalDCEPass();
76 //===----------------------------------------------------------------------===//
77 /// This transform is designed to eliminate available external globals
78 /// (functions or global variables)
80 ModulePass *createEliminateAvailableExternallyPass();
82 //===----------------------------------------------------------------------===//
83 /// createGVExtractionPass - If deleteFn is true, this pass deletes
84 /// the specified global values. Otherwise, it deletes as much of the module as
85 /// possible, except for the global values specified.
87 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
90 //===----------------------------------------------------------------------===//
91 /// This pass performs iterative function importing from other modules.
92 Pass *createFunctionImportPass(const ModuleSummaryIndex *Index = nullptr);
94 //===----------------------------------------------------------------------===//
95 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
96 /// to inline direct function calls to small functions.
98 /// The Threshold can be passed directly, or asked to be computed from the
99 /// given optimization and size optimization arguments.
101 /// The -inline-threshold command line option takes precedence over the
102 /// threshold given here.
103 Pass *createFunctionInliningPass();
104 Pass *createFunctionInliningPass(int Threshold);
105 Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel);
107 //===----------------------------------------------------------------------===//
108 /// createAlwaysInlinerPass - Return a new pass object that inlines only
109 /// functions that are marked as "always_inline".
110 Pass *createAlwaysInlinerPass();
111 Pass *createAlwaysInlinerPass(bool InsertLifetime);
113 //===----------------------------------------------------------------------===//
114 /// createPruneEHPass - Return a new pass object which transforms invoke
115 /// instructions into calls, if the callee can _not_ unwind the stack.
117 Pass *createPruneEHPass();
119 //===----------------------------------------------------------------------===//
120 /// createInternalizePass - This pass loops over all of the functions in the
121 /// input module, internalizing all globals (functions and variables) it can.
123 /// Before internalizing a symbol, the callback \p MustPreserveGV is invoked and
124 /// gives to the client the ability to prevent internalizing specific symbols.
126 /// The symbol in DSOList are internalized if it is safe to drop them from
127 /// the symbol table.
129 /// Note that commandline options that are used with the above function are not
132 createInternalizePass(std::function<bool(const GlobalValue &)> MustPreserveGV);
134 /// createInternalizePass - Same as above, but with an empty exportList.
135 ModulePass *createInternalizePass();
137 //===----------------------------------------------------------------------===//
138 /// createDeadArgEliminationPass - This pass removes arguments from functions
139 /// which are not used by the body of the function.
141 ModulePass *createDeadArgEliminationPass();
143 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
144 /// functions as well. This is definitely not safe, and should only be used by
146 ModulePass *createDeadArgHackingPass();
148 //===----------------------------------------------------------------------===//
149 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
150 /// be passed by value if the number of elements passed is smaller or
151 /// equal to maxElements (maxElements == 0 means always promote).
153 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
155 //===----------------------------------------------------------------------===//
156 /// createIPConstantPropagationPass - This pass propagates constants from call
157 /// sites into the bodies of functions.
159 ModulePass *createIPConstantPropagationPass();
161 //===----------------------------------------------------------------------===//
162 /// createIPSCCPPass - This pass propagates constants from call sites into the
163 /// bodies of functions, and keeps track of whether basic blocks are executable
166 ModulePass *createIPSCCPPass();
168 //===----------------------------------------------------------------------===//
170 /// createLoopExtractorPass - This pass extracts all natural loops from the
171 /// program into a function if it can.
173 Pass *createLoopExtractorPass();
175 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
176 /// program into a function if it can. This is used by bugpoint.
178 Pass *createSingleLoopExtractorPass();
180 /// createBlockExtractorPass - This pass extracts all blocks (except those
181 /// specified in the argument list) from the functions in the module.
183 ModulePass *createBlockExtractorPass();
185 /// createStripDeadPrototypesPass - This pass removes any function declarations
186 /// (prototypes) that are not used.
187 ModulePass *createStripDeadPrototypesPass();
189 //===----------------------------------------------------------------------===//
190 /// createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call
191 /// graph in RPO to deduce and propagate function attributes. Currently it
192 /// only handles synthesizing norecurse attributes.
194 Pass *createReversePostOrderFunctionAttrsPass();
196 //===----------------------------------------------------------------------===//
197 /// createMergeFunctionsPass - This pass discovers identical functions and
200 ModulePass *createMergeFunctionsPass();
202 //===----------------------------------------------------------------------===//
203 /// createPartialInliningPass - This pass inlines parts of functions.
205 ModulePass *createPartialInliningPass();
207 //===----------------------------------------------------------------------===//
208 // createMetaRenamerPass - Rename everything with metasyntatic names.
210 ModulePass *createMetaRenamerPass();
212 //===----------------------------------------------------------------------===//
213 /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
215 ModulePass *createBarrierNoopPass();
217 /// \brief This pass lowers type metadata and the llvm.type.test intrinsic to
219 ModulePass *createLowerTypeTestsPass();
221 /// \brief This pass export CFI checks for use by external modules.
222 ModulePass *createCrossDSOCFIPass();
224 /// \brief This pass implements whole-program devirtualization using type
226 ModulePass *createWholeProgramDevirtPass();
228 //===----------------------------------------------------------------------===//
229 // SampleProfilePass - Loads sample profile data from disk and generates
230 // IR metadata to reflect the profile.
231 ModulePass *createSampleProfileLoaderPass();
232 ModulePass *createSampleProfileLoaderPass(StringRef Name);
234 } // End llvm namespace