LLVM  13.0.0git
IPO.h
Go to the documentation of this file.
1 //===- llvm/Transforms/IPO.h - Interprocedural Transformations --*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This header file defines prototypes for accessor functions that expose passes
10 // in the IPO transformations library.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_TRANSFORMS_IPO_H
15 #define LLVM_TRANSFORMS_IPO_H
16 
17 #include "llvm/ADT/SmallVector.h"
18 #include <functional>
19 #include <vector>
20 
21 namespace llvm {
22 
23 struct InlineParams;
24 class StringRef;
25 class ModuleSummaryIndex;
26 class ModulePass;
27 class Pass;
28 class BasicBlock;
29 class GlobalValue;
30 class raw_ostream;
31 
32 //===----------------------------------------------------------------------===//
33 //
34 // This pass adds !annotation metadata to entries in the
35 // @llvm.global.annotations global constant.
36 //
38 
39 //===----------------------------------------------------------------------===//
40 //
41 // These functions removes symbols from functions and modules. If OnlyDebugInfo
42 // is true, only debugging information is removed from the module.
43 //
44 ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
45 
46 //===----------------------------------------------------------------------===//
47 //
48 // These functions strips symbols from functions and modules.
49 // Only debugging information is not stripped.
50 //
51 ModulePass *createStripNonDebugSymbolsPass();
52 
53 //===----------------------------------------------------------------------===//
54 //
55 // This pass removes llvm.dbg.declare intrinsics.
56 ModulePass *createStripDebugDeclarePass();
57 
58 //===----------------------------------------------------------------------===//
59 //
60 // This pass removes unused symbols' debug info.
61 ModulePass *createStripDeadDebugInfoPass();
62 
63 //===----------------------------------------------------------------------===//
64 /// createConstantMergePass - This function returns a new pass that merges
65 /// duplicate global constants together into a single constant that is shared.
66 /// This is useful because some passes (ie TraceValues) insert a lot of string
67 /// constants into the program, regardless of whether or not they duplicate an
68 /// existing string.
69 ///
70 ModulePass *createConstantMergePass();
71 
72 //===----------------------------------------------------------------------===//
73 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
74 /// non-address taken internal globals.
75 ///
76 ModulePass *createGlobalOptimizerPass();
77 
78 //===----------------------------------------------------------------------===//
79 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
80 /// internal globals (functions or global variables)
81 ///
82 ModulePass *createGlobalDCEPass();
83 
84 //===----------------------------------------------------------------------===//
85 /// This transform is designed to eliminate available external globals
86 /// (functions or global variables)
87 ///
89 
90 //===----------------------------------------------------------------------===//
91 /// createGVExtractionPass - If deleteFn is true, this pass deletes
92 /// the specified global values. Otherwise, it deletes as much of the module as
93 /// possible, except for the global values specified. If keepConstInit is true,
94 /// the initializers of global constants are not deleted even if they are
95 /// unused.
96 ///
97 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
98  deleteFn = false, bool keepConstInit = false);
99 
100 //===----------------------------------------------------------------------===//
101 /// This pass performs iterative function importing from other modules.
103 
104 //===----------------------------------------------------------------------===//
105 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
106 /// to inline direct function calls to small functions.
107 ///
108 /// The Threshold can be passed directly, or asked to be computed from the
109 /// given optimization and size optimization arguments.
110 ///
111 /// The -inline-threshold command line option takes precedence over the
112 /// threshold given here.
115 Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel,
116  bool DisableInlineHotCallSite);
117 Pass *createFunctionInliningPass(InlineParams &Params);
118 
119 //===----------------------------------------------------------------------===//
120 /// createPruneEHPass - Return a new pass object which transforms invoke
121 /// instructions into calls, if the callee can _not_ unwind the stack.
122 ///
124 
125 //===----------------------------------------------------------------------===//
126 /// createInternalizePass - This pass loops over all of the functions in the
127 /// input module, internalizing all globals (functions and variables) it can.
128 ////
129 /// Before internalizing a symbol, the callback \p MustPreserveGV is invoked and
130 /// gives to the client the ability to prevent internalizing specific symbols.
131 ///
132 /// The symbol in DSOList are internalized if it is safe to drop them from
133 /// the symbol table.
134 ///
135 /// Note that commandline options that are used with the above function are not
136 /// used now!
137 ModulePass *
138 createInternalizePass(std::function<bool(const GlobalValue &)> MustPreserveGV);
139 
140 /// createInternalizePass - Same as above, but with an empty exportList.
141 ModulePass *createInternalizePass();
142 
143 //===----------------------------------------------------------------------===//
144 /// createDeadArgEliminationPass - This pass removes arguments from functions
145 /// which are not used by the body of the function.
146 ///
147 ModulePass *createDeadArgEliminationPass();
148 
149 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
150 /// functions as well. This is definitely not safe, and should only be used by
151 /// bugpoint.
152 ModulePass *createDeadArgHackingPass();
153 
154 //===----------------------------------------------------------------------===//
155 /// createArgumentPromotionPass - This pass promotes "by reference" arguments to
156 /// be passed by value if the number of elements passed is smaller or
157 /// equal to maxElements (maxElements == 0 means always promote).
158 ///
159 Pass *createArgumentPromotionPass(unsigned maxElements = 3);
160 
161 //===----------------------------------------------------------------------===//
162 /// createOpenMPOptLegacyPass - OpenMP specific optimizations.
164 
165 //===----------------------------------------------------------------------===//
166 /// createIPSCCPPass - This pass propagates constants from call sites into the
167 /// bodies of functions, and keeps track of whether basic blocks are executable
168 /// in the process.
169 ///
170 ModulePass *createIPSCCPPass();
171 
172 //===----------------------------------------------------------------------===//
173 //
174 /// createLoopExtractorPass - This pass extracts all natural loops from the
175 /// program into a function if it can.
176 ///
178 
179 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
180 /// program into a function if it can. This is used by bugpoint.
181 ///
183 
184 /// createBlockExtractorPass - This pass extracts all the specified blocks
185 /// from the functions in the module.
186 ///
187 ModulePass *createBlockExtractorPass();
188 ModulePass *
189 createBlockExtractorPass(const SmallVectorImpl<BasicBlock *> &BlocksToExtract,
190  bool EraseFunctions);
191 ModulePass *
192 createBlockExtractorPass(const SmallVectorImpl<SmallVector<BasicBlock *, 16>>
193  &GroupsOfBlocksToExtract,
194  bool EraseFunctions);
195 
196 /// createStripDeadPrototypesPass - This pass removes any function declarations
197 /// (prototypes) that are not used.
198 ModulePass *createStripDeadPrototypesPass();
199 
200 //===----------------------------------------------------------------------===//
201 /// createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call
202 /// graph in RPO to deduce and propagate function attributes. Currently it
203 /// only handles synthesizing norecurse attributes.
204 ///
206 
207 //===----------------------------------------------------------------------===//
208 /// createMergeFunctionsPass - This pass discovers identical functions and
209 /// collapses them.
210 ///
211 ModulePass *createMergeFunctionsPass();
212 
213 //===----------------------------------------------------------------------===//
214 /// createHotColdSplittingPass - This pass outlines cold blocks into a separate
215 /// function(s).
216 ModulePass *createHotColdSplittingPass();
217 
218 //===----------------------------------------------------------------------===//
219 /// createIROutlinerPass - This pass finds similar code regions and factors
220 /// those regions out into functions.
221 ModulePass *createIROutlinerPass();
222 
223 //===----------------------------------------------------------------------===//
224 /// createPartialInliningPass - This pass inlines parts of functions.
225 ///
226 ModulePass *createPartialInliningPass();
227 
228 //===----------------------------------------------------------------------===//
229 /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
230 /// manager.
231 ModulePass *createBarrierNoopPass();
232 
233 /// createCalledValuePropagationPass - Attach metadata to indirct call sites
234 /// indicating the set of functions they may target at run-time.
236 
237 /// What to do with the summary when running passes that operate on it.
238 enum class PassSummaryAction {
239  None, ///< Do nothing.
240  Import, ///< Import information from summary.
241  Export, ///< Export information to summary.
242 };
243 
244 /// This pass lowers type metadata and the llvm.type.test intrinsic to
245 /// bitsets.
246 ///
247 /// The behavior depends on the summary arguments:
248 /// - If ExportSummary is non-null, this pass will export type identifiers to
249 /// the given summary.
250 /// - If ImportSummary is non-null, this pass will import type identifiers from
251 /// the given summary.
252 /// - Otherwise, if both are null and DropTypeTests is true, all type test
253 /// assume sequences will be removed from the IR.
254 /// It is invalid for both ExportSummary and ImportSummary to be non-null
255 /// unless DropTypeTests is true.
256 ModulePass *createLowerTypeTestsPass(ModuleSummaryIndex *ExportSummary,
257  const ModuleSummaryIndex *ImportSummary,
258  bool DropTypeTests = false);
259 
260 /// This pass export CFI checks for use by external modules.
261 ModulePass *createCrossDSOCFIPass();
262 
263 /// This pass implements whole-program devirtualization using type
264 /// metadata.
265 ///
266 /// The behavior depends on the summary arguments:
267 /// - If ExportSummary is non-null, this pass will export type identifiers to
268 /// the given summary.
269 /// - Otherwise, if ImportSummary is non-null, this pass will import type
270 /// identifiers from the given summary.
271 /// - Otherwise it does neither.
272 /// It is invalid for both ExportSummary and ImportSummary to be non-null.
273 ModulePass *
274 createWholeProgramDevirtPass(ModuleSummaryIndex *ExportSummary,
275  const ModuleSummaryIndex *ImportSummary);
276 
277 /// This pass splits globals into pieces for the benefit of whole-program
278 /// devirtualization and control-flow integrity.
279 ModulePass *createGlobalSplitPass();
280 
281 //===----------------------------------------------------------------------===//
282 // SampleProfilePass - Loads sample profile data from disk and generates
283 // IR metadata to reflect the profile.
284 ModulePass *createSampleProfileLoaderPass();
285 ModulePass *createSampleProfileLoaderPass(StringRef Name);
286 
287 /// Write ThinLTO-ready bitcode to Str.
288 ModulePass *createWriteThinLTOBitcodePass(raw_ostream &Str,
289  raw_ostream *ThinLinkOS = nullptr);
290 
291 } // End llvm namespace
292 
293 #endif
llvm
Definition: AllocatorList.h:23
llvm::createCrossDSOCFIPass
ModulePass * createCrossDSOCFIPass()
This pass export CFI checks for use by external modules.
Pass
print lazy value Lazy Value Info Printer Pass
Definition: LazyValueInfo.cpp:1947
llvm::createLowerTypeTestsPass
ModulePass * createLowerTypeTestsPass(ModuleSummaryIndex *ExportSummary, const ModuleSummaryIndex *ImportSummary, bool DropTypeTests=false)
This pass lowers type metadata and the llvm.type.test intrinsic to bitsets.
llvm::createPruneEHPass
Pass * createPruneEHPass()
createPruneEHPass - Return a new pass object which transforms invoke instructions into calls,...
Definition: PruneEH.cpp:63
llvm::createSampleProfileLoaderPass
ModulePass * createSampleProfileLoaderPass()
Definition: SampleProfile.cpp:1828
llvm::createDeadArgEliminationPass
ModulePass * createDeadArgEliminationPass()
createDeadArgEliminationPass - This pass removes arguments from functions which are not used by the b...
llvm::createBarrierNoopPass
ModulePass * createBarrierNoopPass()
createBarrierNoopPass - This pass is purely a module pass barrier in a pass manager.
Definition: BarrierNoopPass.cpp:43
llvm::createMergeFunctionsPass
ModulePass * createMergeFunctionsPass()
createMergeFunctionsPass - This pass discovers identical functions and collapses them.
llvm::PassSummaryAction
PassSummaryAction
What to do with the summary when running passes that operate on it.
Definition: IPO.h:238
llvm::createStripDebugDeclarePass
ModulePass * createStripDebugDeclarePass()
llvm::PassSummaryAction::Export
@ Export
Export information to summary.
llvm::createStripDeadPrototypesPass
ModulePass * createStripDeadPrototypesPass()
createStripDeadPrototypesPass - This pass removes any function declarations (prototypes) that are not...
llvm::createLoopExtractorPass
Pass * createLoopExtractorPass()
createLoopExtractorPass - This pass extracts all natural loops from the program into a function if it...
llvm::createSingleLoopExtractorPass
Pass * createSingleLoopExtractorPass()
createSingleLoopExtractorPass - This pass extracts one natural loop from the program into a function ...
Definition: LoopExtractor.cpp:262
llvm::createWholeProgramDevirtPass
ModulePass * createWholeProgramDevirtPass(ModuleSummaryIndex *ExportSummary, const ModuleSummaryIndex *ImportSummary)
This pass implements whole-program devirtualization using type metadata.
Definition: WholeProgramDevirt.cpp:748
llvm::createGlobalSplitPass
ModulePass * createGlobalSplitPass()
This pass splits globals into pieces for the benefit of whole-program devirtualization and control-fl...
Definition: GlobalSplit.cpp:188
llvm::PassSummaryAction::None
@ None
Do nothing.
llvm::createBlockExtractorPass
ModulePass * createBlockExtractorPass()
createBlockExtractorPass - This pass extracts all the specified blocks from the functions in the modu...
llvm::createDeadArgHackingPass
ModulePass * createDeadArgHackingPass()
DeadArgHacking pass - Same as DAE, but delete arguments of external functions as well.
Definition: DeadArgumentElimination.cpp:120
llvm::createGlobalOptimizerPass
ModulePass * createGlobalOptimizerPass()
createGlobalOptimizerPass - This function returns a new pass that optimizes non-address taken interna...
Definition: GlobalOpt.cpp:2704
llvm::PassSummaryAction::Import
@ Import
Import information from summary.
llvm::createHotColdSplittingPass
ModulePass * createHotColdSplittingPass()
createHotColdSplittingPass - This pass outlines cold blocks into a separate function(s).
Definition: HotColdSplitting.cpp:792
llvm::createFunctionInliningPass
Pass * createFunctionInliningPass()
createFunctionInliningPass - Return a new pass object that uses a heuristic to inline direct function...
Definition: InlineSimple.cpp:97
llvm::createIPSCCPPass
ModulePass * createIPSCCPPass()
createIPSCCPPass - This pass propagates constants from call sites into the bodies of functions,...
Definition: SCCP.cpp:105
llvm::createReversePostOrderFunctionAttrsPass
Pass * createReversePostOrderFunctionAttrsPass()
createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call graph in RPO to deduce and...
Definition: FunctionAttrs.cpp:1734
llvm::createGlobalDCEPass
ModulePass * createGlobalDCEPass()
createGlobalDCEPass - This transform is designed to eliminate unreachable internal globals (functions...
llvm::ISD::BasicBlock
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:64
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
llvm::createArgumentPromotionPass
Pass * createArgumentPromotionPass(unsigned maxElements=3)
createArgumentPromotionPass - This pass promotes "by reference" arguments to be passed by value if th...
Definition: ArgumentPromotion.cpp:1105
llvm::createStripSymbolsPass
ModulePass * createStripSymbolsPass(bool OnlyDebugInfo=false)
llvm::createStripDeadDebugInfoPass
ModulePass * createStripDeadDebugInfoPass()
llvm::createIROutlinerPass
ModulePass * createIROutlinerPass()
createIROutlinerPass - This pass finds similar code regions and factors those regions out into functi...
Definition: IROutliner.cpp:1761
llvm::createCalledValuePropagationPass
ModulePass * createCalledValuePropagationPass()
createCalledValuePropagationPass - Attach metadata to indirct call sites indicating the set of functi...
llvm::createFunctionImportPass
Pass * createFunctionImportPass()
This pass performs iterative function importing from other modules.
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::createStripNonDebugSymbolsPass
ModulePass * createStripNonDebugSymbolsPass()
llvm::createInternalizePass
ModulePass * createInternalizePass(std::function< bool(const GlobalValue &)> MustPreserveGV)
createInternalizePass - This pass loops over all of the functions in the input module,...
Definition: Internalize.cpp:309
llvm::createEliminateAvailableExternallyPass
ModulePass * createEliminateAvailableExternallyPass()
This transform is designed to eliminate available external globals (functions or global variables)
SmallVector.h
llvm::createConstantMergePass
ModulePass * createConstantMergePass()
createConstantMergePass - This function returns a new pass that merges duplicate global constants tog...
llvm::createWriteThinLTOBitcodePass
ModulePass * createWriteThinLTOBitcodePass(raw_ostream &Str, raw_ostream *ThinLinkOS=nullptr)
Write ThinLTO-ready bitcode to Str.
Definition: ThinLTOBitcodeWriter.cpp:563
Threshold
static cl::opt< unsigned > Threshold("loop-unswitch-threshold", cl::desc("Max loop size to unswitch"), cl::init(100), cl::Hidden)
llvm::createPartialInliningPass
ModulePass * createPartialInliningPass()
createPartialInliningPass - This pass inlines parts of functions.
Definition: PartialInlining.cpp:1524
llvm::createGVExtractionPass
ModulePass * createGVExtractionPass(std::vector< GlobalValue * > &GVs, bool deleteFn=false, bool keepConstInit=false)
createGVExtractionPass - If deleteFn is true, this pass deletes the specified global values.
Definition: ExtractGV.cpp:160
llvm::createAnnotation2MetadataLegacyPass
ModulePass * createAnnotation2MetadataLegacyPass()
Definition: Annotation2Metadata.cpp:98
llvm::createOpenMPOptCGSCCLegacyPass
Pass * createOpenMPOptCGSCCLegacyPass()
createOpenMPOptLegacyPass - OpenMP specific optimizations.
Definition: OpenMPOpt.cpp:2695