LLVM: include/llvm/Transforms/Utils/Cloning.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef LLVM_TRANSFORMS_UTILS_CLONING_H
18#define LLVM_TRANSFORMS_UTILS_CLONING_H
19
29#include
30#include
31#include
32
33namespace llvm {
34
51
52
56
57
58
59
60
61LLVM_ABI std::unique_ptr
64
65
66
68
70
71
72
74
75
76
77
79
80
81
82
84
85
86
87
89
91
93 return OrigVMap.lookup(From) != To;
94 }
95};
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
134 const Twine &NameSuffix = "", Function *F = nullptr,
135 ClonedCodeInfo *CodeInfo = nullptr, bool MapAtoms = true);
136
137
138
140
141
142
143
144
145
146
147
148
149
150
151
153 ClonedCodeInfo *CodeInfo = nullptr);
154
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
189 SmallVectorImpl<ReturnInst *> &Returns,
190 const char *NameSuffix = "",
191 ClonedCodeInfo *CodeInfo = nullptr,
192 ValueMapTypeRemapper *TypeMapper = nullptr,
193 ValueMaterializer *Materializer = nullptr);
194
195
196
200 ValueMapTypeRemapper *TypeMapper = nullptr,
201 ValueMaterializer *Materializer = nullptr);
202
203
204
205
206
207
208
209
210
214 ValueMapTypeRemapper *TypeMapper = nullptr,
215 ValueMaterializer *Materializer = nullptr,
217
218
220 Function &NewFunc, const Function &OldFunc, ValueToValueMapTy &VMap,
221 RemapFlags RemapFlag, SmallVectorImpl<ReturnInst *> &Returns,
222 const char *NameSuffix = "", ClonedCodeInfo *CodeInfo = nullptr,
223 ValueMapTypeRemapper *TypeMapper = nullptr,
224 ValueMaterializer *Materializer = nullptr,
226
228 Function *NewFunc, const Function *OldFunc, const Instruction *StartingInst,
230 SmallVectorImpl<ReturnInst *> &Returns, const char *NameSuffix = "",
231 ClonedCodeInfo *CodeInfo = nullptr);
232
233
234
235
236
237
238
239
240
241
242
243
245 Function *NewFunc, const Function *OldFunc, ValueToValueMapTy &VMap,
246 bool ModuleLevelChanges, SmallVectorImpl<ReturnInst *> &Returns,
247 const char *NameSuffix = "", ClonedCodeInfo *CodeInfo = nullptr);
248
249
250
252public:
260
261
262
266
267
268
270
271
272
274
275
276
277
278
279
281
284
285
286
288
296};
297
298
299
300
301
302
304 InlineFunctionInfo &IFI);
305
306
307
308
309
310
311
312
313
314
315
317 bool MergeAttributes = false,
318 AAResults *CalleeAAR = nullptr,
319 bool InsertLifetime = true,
320 Function *ForwardVarArgsTo = nullptr,
321 OptimizationRemarkEmitter *ORE = nullptr);
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
346 bool MergeAttributes = false,
347 AAResults *CalleeAAR = nullptr,
348 bool InsertLifetime = true,
349 Function *ForwardVarArgsTo = nullptr,
350 OptimizationRemarkEmitter *ORE = nullptr);
351
352
353
354
355
357 PGOContextualProfile &CtxProf,
358 bool MergeAttributes = false,
359 AAResults *CalleeAAR = nullptr,
360 bool InsertLifetime = true,
361 Function *ForwardVarArgsTo = nullptr,
362 OptimizationRemarkEmitter *ORE = nullptr);
363
364
365
366
367
368
369
372 const Twine &NameSuffix, LoopInfo *LI,
373 DominatorTree *DT,
374 SmallVectorImpl<BasicBlock *> &Blocks);
375
376
379
380
381
382
383
384
385
387 BasicBlock *BB, BasicBlock *PredBB, Instruction *StopAt,
389
390
391
392
394 Function *Callee, int64_t EntryDelta,
395 const ValueMap<const Value *, WeakTrackingVH> *VMap = nullptr);
396
397
398
399
402 SmallVectorImpl<MDNode *> &NoAliasDeclScopes);
403
404
405
406
410 SmallVectorImpl<MDNode *> &NoAliasDeclScopes);
411
412
413
414
415
416
418 DenseMap<MDNode *, MDNode *> &ClonedScopes,
419 StringRef Ext, LLVMContext &Context);
420
421
422
423
426 const DenseMap<MDNode *, MDNode *> &ClonedScopes,
427 LLVMContext &Context);
428
429
430
431
434 LLVMContext &Context, StringRef Ext);
435
436
437
438
440 Instruction *IStart, Instruction *IEnd,
441 LLVMContext &Context, StringRef Ext);
442}
443
444#endif
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file defines the SmallVector class.
an instruction to allocate memory on the stack
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
InstListType::iterator iterator
Instruction iterators...
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Utility to find all debug info in a module.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Value * ConvergenceControlToken
Definition Cloning.h:282
ProfileSummaryInfo * PSI
Definition Cloning.h:264
bool UpdateProfile
Update profile for callee as well as cloned version.
Definition Cloning.h:287
Instruction * CallSiteEHPad
Definition Cloning.h:283
function_ref< AssumptionCache &(Function &)> GetAssumptionCache
If non-null, InlineFunction will update the callgraph to reflect the changes it makes.
Definition Cloning.h:263
BlockFrequencyInfo * CalleeBFI
Definition Cloning.h:265
SmallVector< AllocaInst *, 4 > StaticAllocas
InlineFunction fills this in with all static allocas that get copied into the caller.
Definition Cloning.h:269
void reset()
Definition Cloning.h:289
InlineFunctionInfo(function_ref< AssumptionCache &(Function &)> GetAssumptionCache=nullptr, ProfileSummaryInfo *PSI=nullptr, BlockFrequencyInfo *CallerBFI=nullptr, BlockFrequencyInfo *CalleeBFI=nullptr, bool UpdateProfile=true)
Definition Cloning.h:253
BlockFrequencyInfo * CallerBFI
Definition Cloning.h:265
SmallVector< WeakTrackingVH, 8 > InlinedCalls
InlineFunction fills this in with callsites that were inlined from the callee.
Definition Cloning.h:273
SmallVector< CallBase *, 8 > InlinedCallSites
All of the new call sites inlined into the caller.
Definition Cloning.h:280
Represents a single loop in the control flow graph.
A Module instance is used to store all the information related to an LLVM module.
The instrumented contextual profile, produced by the CtxProfAnalysis.
Analysis providing profile information.
Return a value (possibly void), from a function.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LLVM Value Representation.
An efficient, type-erasing, non-owning reference to a callable.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void CloneFunctionAttributesInto(Function *NewFunc, const Function *OldFunc, ValueToValueMapTy &VMap, bool ModuleLevelChanges, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
Clone OldFunc's attributes into NewFunc, transforming values based on the mappings in VMap.
std::function< bool(const Metadata *)> MetadataPredicate
static cl::opt< unsigned long > StopAt("sbvec-stop-at", cl::init(StopAtDisabled), cl::Hidden, cl::desc("Vectorize if the invocation count is < than this. 0 " "disables vectorization."))
LLVM_ABI InlineResult InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, bool MergeAttributes=false, AAResults *CalleeAAR=nullptr, bool InsertLifetime=true, Function *ForwardVarArgsTo=nullptr, OptimizationRemarkEmitter *ORE=nullptr)
This function inlines the called function into the basic block of the caller.
LLVM_ABI BasicBlock * CloneBasicBlock(const BasicBlock *BB, ValueToValueMapTy &VMap, const Twine &NameSuffix="", Function *F=nullptr, ClonedCodeInfo *CodeInfo=nullptr, bool MapAtoms=true)
Return a copy of the specified basic block, but without embedding the block into a particular functio...
LLVM_ABI BasicBlock * DuplicateInstructionsInSplitBetween(BasicBlock *BB, BasicBlock *PredBB, Instruction *StopAt, ValueToValueMapTy &ValueMapping, DomTreeUpdater &DTU)
Split edge between BB and PredBB and duplicate all non-Phi instructions from BB between its beginning...
LLVM_ABI InlineResult CanInlineCallSite(const CallBase &CB, InlineFunctionInfo &IFI)
Check if it is legal to perform inlining of the function called by CB into the caller at this particu...
LLVM_ABI void CloneFunctionMetadataInto(Function &NewFunc, const Function &OldFunc, ValueToValueMapTy &VMap, RemapFlags RemapFlag, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr, const MetadataPredicate *IdentityMD=nullptr)
Clone OldFunc's metadata into NewFunc.
LLVM_ABI Loop * cloneLoopWithPreheader(BasicBlock *Before, BasicBlock *LoopDomBB, Loop *OrigLoop, ValueToValueMapTy &VMap, const Twine &NameSuffix, LoopInfo *LI, DominatorTree *DT, SmallVectorImpl< BasicBlock * > &Blocks)
Clones a loop OrigLoop.
RemapFlags
These are flags that the value mapping APIs allow.
LLVM_ABI void CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc, ValueToValueMapTy &VMap, bool ModuleLevelChanges, SmallVectorImpl< ReturnInst * > &Returns, const char *NameSuffix="", ClonedCodeInfo *CodeInfo=nullptr)
This works exactly like CloneFunctionInto, except that it does some simple constant prop and DCE on t...
LLVM_ABI void InlineFunctionImpl(CallBase &CB, InlineFunctionInfo &IFI, bool MergeAttributes=false, AAResults *CalleeAAR=nullptr, bool InsertLifetime=true, Function *ForwardVarArgsTo=nullptr, OptimizationRemarkEmitter *ORE=nullptr)
This should generally not be used, use InlineFunction instead.
LLVM_ABI void cloneNoAliasScopes(ArrayRef< MDNode * > NoAliasDeclScopes, DenseMap< MDNode *, MDNode * > &ClonedScopes, StringRef Ext, LLVMContext &Context)
Duplicate the specified list of noalias decl scopes.
LLVM_ABI void CloneFunctionBodyInto(Function &NewFunc, const Function &OldFunc, ValueToValueMapTy &VMap, RemapFlags RemapFlag, SmallVectorImpl< ReturnInst * > &Returns, const char *NameSuffix="", ClonedCodeInfo *CodeInfo=nullptr, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr, const MetadataPredicate *IdentityMD=nullptr)
Clone OldFunc's body into NewFunc.
LLVM_ABI void updateProfileCallee(Function *Callee, int64_t EntryDelta, const ValueMap< const Value *, WeakTrackingVH > *VMap=nullptr)
Updates profile information by adjusting the entry count by adding EntryDelta then scaling callsite i...
LLVM_ABI void adaptNoAliasScopes(llvm::Instruction *I, const DenseMap< MDNode *, MDNode * > &ClonedScopes, LLVMContext &Context)
Adapt the metadata for the specified instruction according to the provided mapping.
LLVM_ABI void cloneAndAdaptNoAliasScopes(ArrayRef< MDNode * > NoAliasDeclScopes, ArrayRef< BasicBlock * > NewBlocks, LLVMContext &Context, StringRef Ext)
Clone the specified noalias decl scopes.
LLVM_ABI void remapInstructionsInBlocks(ArrayRef< BasicBlock * > Blocks, ValueToValueMapTy &VMap)
Remaps instructions in Blocks using the mapping in VMap.
ArrayRef(const T &OneElt) -> ArrayRef< T >
CloneFunctionChangeType
Definition Cloning.h:155
@ DifferentModule
Definition Cloning.h:158
@ LocalChangesOnly
Definition Cloning.h:156
@ ClonedModule
Definition Cloning.h:159
@ GlobalChanges
Definition Cloning.h:157
ValueMap< const Value *, WeakTrackingVH > ValueToValueMapTy
LLVM_ABI void CloneFunctionInto(Function *NewFunc, const Function *OldFunc, ValueToValueMapTy &VMap, CloneFunctionChangeType Changes, SmallVectorImpl< ReturnInst * > &Returns, const char *NameSuffix="", ClonedCodeInfo *CodeInfo=nullptr, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
Clone OldFunc into NewFunc, transforming the old arguments into references to VMap values.
LLVM_ABI void identifyNoAliasScopesToClone(ArrayRef< BasicBlock * > BBs, SmallVectorImpl< MDNode * > &NoAliasDeclScopes)
Find the 'llvm.experimental.noalias.scope.decl' intrinsics in the specified basic blocks and extract ...
LLVM_ABI std::unique_ptr< Module > CloneModule(const Module &M)
Return an exact copy of the specified module.
LLVM_ABI void CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc, const Instruction *StartingInst, ValueToValueMapTy &VMap, bool ModuleLevelChanges, SmallVectorImpl< ReturnInst * > &Returns, const char *NameSuffix="", ClonedCodeInfo *CodeInfo=nullptr)
This works like CloneAndPruneFunctionInto, except that it does not clone the entire function.
LLVM_ABI Function * CloneFunction(Function *F, ValueToValueMapTy &VMap, ClonedCodeInfo *CodeInfo=nullptr)
Return a copy of the specified function and add it to that function's module.
LLVM_ABI void mapAtomInstance(const DebugLoc &DL, ValueToValueMapTy &VMap)
Mark a cloned instruction as a new instance so that its source loc can be updated when remapped.
bool ContainsDynamicAllocas
This is set to true if the cloned code contains a 'dynamic' alloca.
Definition Cloning.h:78
bool isSimplified(const Value *From, const Value *To) const
Definition Cloning.h:92
bool ContainsCalls
This is set to true if the cloned code contains a normal call instruction.
Definition Cloning.h:69
bool ContainsMemProfMetadata
This is set to true if there is memprof related metadata (memprof or callsite metadata) in the cloned...
Definition Cloning.h:73
DenseMap< const Value *, const Value * > OrigVMap
Like VMap, but maps only unsimplified instructions.
Definition Cloning.h:88
std::vector< WeakTrackingVH > OperandBundleCallSites
All cloned call sites that have operand bundles attached are appended to this vector.
Definition Cloning.h:83