LLVM  16.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 ModulePass;
25 class Pass;
26 class BasicBlock;
27 class GlobalValue;
28 class raw_ostream;
29 
30 //===----------------------------------------------------------------------===//
31 //
32 // This pass adds !annotation metadata to entries in the
33 // @llvm.global.annotations global constant.
34 //
36 
37 //===----------------------------------------------------------------------===//
38 //
39 // These functions removes symbols from functions and modules. If OnlyDebugInfo
40 // is true, only debugging information is removed from the module.
41 //
42 ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
43 
44 //===----------------------------------------------------------------------===//
45 //
46 // These functions strips symbols from functions and modules.
47 // Only debugging information is not stripped.
48 //
49 ModulePass *createStripNonDebugSymbolsPass();
50 
51 //===----------------------------------------------------------------------===//
52 //
53 // This pass removes llvm.dbg.declare intrinsics.
54 ModulePass *createStripDebugDeclarePass();
55 
56 //===----------------------------------------------------------------------===//
57 //
58 // This pass removes unused symbols' debug info.
59 ModulePass *createStripDeadDebugInfoPass();
60 
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
66 /// existing string.
67 ///
68 ModulePass *createConstantMergePass();
69 
70 //===----------------------------------------------------------------------===//
71 /// createGlobalOptimizerPass - This function returns a new pass that optimizes
72 /// non-address taken internal globals.
73 ///
74 ModulePass *createGlobalOptimizerPass();
75 
76 //===----------------------------------------------------------------------===//
77 /// createGlobalDCEPass - This transform is designed to eliminate unreachable
78 /// internal globals (functions or global variables)
79 ///
80 ModulePass *createGlobalDCEPass();
81 
82 //===----------------------------------------------------------------------===//
83 /// This transform is designed to eliminate available external globals
84 /// (functions or global variables)
85 ///
87 
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. If keepConstInit is true,
92 /// the initializers of global constants are not deleted even if they are
93 /// unused.
94 ///
95 ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool
96  deleteFn = false, bool keepConstInit = false);
97 
98 //===----------------------------------------------------------------------===//
99 /// createFunctionInliningPass - Return a new pass object that uses a heuristic
100 /// to inline direct function calls to small functions.
101 ///
102 /// The Threshold can be passed directly, or asked to be computed from the
103 /// given optimization and size optimization arguments.
104 ///
105 /// The -inline-threshold command line option takes precedence over the
106 /// threshold given here.
108 Pass *createFunctionInliningPass(int Threshold);
109 Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel,
110  bool DisableInlineHotCallSite);
111 Pass *createFunctionInliningPass(InlineParams &Params);
112 
113 //===----------------------------------------------------------------------===//
114 /// createInternalizePass - This pass loops over all of the functions in the
115 /// input module, internalizing all globals (functions and variables) it can.
116 ////
117 /// Before internalizing a symbol, the callback \p MustPreserveGV is invoked and
118 /// gives to the client the ability to prevent internalizing specific symbols.
119 ///
120 /// The symbol in DSOList are internalized if it is safe to drop them from
121 /// the symbol table.
122 ///
123 /// Note that commandline options that are used with the above function are not
124 /// used now!
125 ModulePass *
126 createInternalizePass(std::function<bool(const GlobalValue &)> MustPreserveGV);
127 
128 /// createInternalizePass - Same as above, but with an empty exportList.
129 ModulePass *createInternalizePass();
130 
131 //===----------------------------------------------------------------------===//
132 /// createDeadArgEliminationPass - This pass removes arguments from functions
133 /// which are not used by the body of the function.
134 ///
135 ModulePass *createDeadArgEliminationPass();
136 
137 /// DeadArgHacking pass - Same as DAE, but delete arguments of external
138 /// functions as well. This is definitely not safe, and should only be used by
139 /// bugpoint.
140 ModulePass *createDeadArgHackingPass();
141 
142 //===----------------------------------------------------------------------===//
143 /// createOpenMPOptLegacyPass - OpenMP specific optimizations.
145 
146 //===----------------------------------------------------------------------===//
147 /// createIPSCCPPass - This pass propagates constants from call sites into the
148 /// bodies of functions, and keeps track of whether basic blocks are executable
149 /// in the process.
150 ///
151 ModulePass *createIPSCCPPass();
152 
153 //===----------------------------------------------------------------------===//
154 /// createFunctionSpecializationPass - This pass propagates constants from call
155 /// sites to the specialized version of the callee function.
157 
158 //===----------------------------------------------------------------------===//
159 //
160 /// createLoopExtractorPass - This pass extracts all natural loops from the
161 /// program into a function if it can.
162 ///
164 
165 /// createSingleLoopExtractorPass - This pass extracts one natural loop from the
166 /// program into a function if it can. This is used by bugpoint.
167 ///
169 
170 /// createBlockExtractorPass - This pass extracts all the specified blocks
171 /// from the functions in the module.
172 ///
173 ModulePass *createBlockExtractorPass();
174 ModulePass *
175 createBlockExtractorPass(const SmallVectorImpl<BasicBlock *> &BlocksToExtract,
176  bool EraseFunctions);
177 ModulePass *
178 createBlockExtractorPass(const SmallVectorImpl<SmallVector<BasicBlock *, 16>>
179  &GroupsOfBlocksToExtract,
180  bool EraseFunctions);
181 
182 /// createStripDeadPrototypesPass - This pass removes any function declarations
183 /// (prototypes) that are not used.
184 ModulePass *createStripDeadPrototypesPass();
185 
186 //===----------------------------------------------------------------------===//
187 /// createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call
188 /// graph in RPO to deduce and propagate function attributes. Currently it
189 /// only handles synthesizing norecurse attributes.
190 ///
192 
193 //===----------------------------------------------------------------------===//
194 /// createMergeFunctionsPass - This pass discovers identical functions and
195 /// collapses them.
196 ///
197 ModulePass *createMergeFunctionsPass();
198 
199 //===----------------------------------------------------------------------===//
200 /// createHotColdSplittingPass - This pass outlines cold blocks into a separate
201 /// function(s).
202 ModulePass *createHotColdSplittingPass();
203 
204 //===----------------------------------------------------------------------===//
205 /// createIROutlinerPass - This pass finds similar code regions and factors
206 /// those regions out into functions.
207 ModulePass *createIROutlinerPass();
208 
209 //===----------------------------------------------------------------------===//
210 /// createPartialInliningPass - This pass inlines parts of functions.
211 ///
212 ModulePass *createPartialInliningPass();
213 
214 //===----------------------------------------------------------------------===//
215 /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
216 /// manager.
217 ModulePass *createBarrierNoopPass();
218 
219 /// createCalledValuePropagationPass - Attach metadata to indirct call sites
220 /// indicating the set of functions they may target at run-time.
222 
223 /// What to do with the summary when running passes that operate on it.
224 enum class PassSummaryAction {
225  None, ///< Do nothing.
226  Import, ///< Import information from summary.
227  Export, ///< Export information to summary.
228 };
229 
230 /// This pass export CFI checks for use by external modules.
231 ModulePass *createCrossDSOCFIPass();
232 
233 /// This pass splits globals into pieces for the benefit of whole-program
234 /// devirtualization and control-flow integrity.
235 ModulePass *createGlobalSplitPass();
236 
237 } // End llvm namespace
238 
239 #endif
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
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:1979
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:224
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:257
llvm::createGlobalSplitPass
ModulePass * createGlobalSplitPass()
This pass splits globals into pieces for the benefit of whole-program devirtualization and control-fl...
Definition: GlobalSplit.cpp:185
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:118
llvm::createGlobalOptimizerPass
ModulePass * createGlobalOptimizerPass()
createGlobalOptimizerPass - This function returns a new pass that optimizes non-address taken interna...
Definition: GlobalOpt.cpp:2623
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:781
llvm::createFunctionInliningPass
Pass * createFunctionInliningPass()
createFunctionInliningPass - Return a new pass object that uses a heuristic to inline direct function...
Definition: InlineSimple.cpp:91
llvm::createIPSCCPPass
ModulePass * createIPSCCPPass()
createIPSCCPPass - This pass propagates constants from call sites into the bodies of functions,...
Definition: SCCP.cpp:107
llvm::createReversePostOrderFunctionAttrsPass
Pass * createReversePostOrderFunctionAttrsPass()
createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call graph in RPO to deduce and...
Definition: FunctionAttrs.cpp:1959
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:71
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:82
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:3087
llvm::createCalledValuePropagationPass
ModulePass * createCalledValuePropagationPass()
createCalledValuePropagationPass - Attach metadata to indirct call sites indicating the set of functi...
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:328
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::createPartialInliningPass
ModulePass * createPartialInliningPass()
createPartialInliningPass - This pass inlines parts of functions.
Definition: PartialInlining.cpp:1523
llvm::createFunctionSpecializationPass
ModulePass * createFunctionSpecializationPass()
createFunctionSpecializationPass - This pass propagates constants from call sites to the specialized ...
Definition: SCCP.cpp:196
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:154
llvm::createAnnotation2MetadataLegacyPass
ModulePass * createAnnotation2MetadataLegacyPass()
Definition: Annotation2Metadata.cpp:98
llvm::createOpenMPOptCGSCCLegacyPass
Pass * createOpenMPOptCGSCCLegacyPass()
createOpenMPOptLegacyPass - OpenMP specific optimizations.
Definition: OpenMPOpt.cpp:5287