17#ifndef LLVM_TRANSFORMS_UTILS_CLONING_H
18#define LLVM_TRANSFORMS_UTILS_CLONING_H
157 const Twine &NameSuffix =
"",
Function *
F =
nullptr,
158 ClonedCodeInfo *CodeInfo =
nullptr,
bool MapAtoms =
true);
176 ClonedCodeInfo *CodeInfo =
nullptr);
212 SmallVectorImpl<ReturnInst *> &Returns,
213 const char *NameSuffix =
"",
214 ClonedCodeInfo *CodeInfo =
nullptr,
215 ValueMapTypeRemapper *TypeMapper =
nullptr,
216 ValueMaterializer *Materializer =
nullptr);
223 ValueMapTypeRemapper *TypeMapper =
nullptr,
224 ValueMaterializer *Materializer =
nullptr);
237 ValueMapTypeRemapper *TypeMapper =
nullptr,
238 ValueMaterializer *Materializer =
nullptr,
244 RemapFlags RemapFlag, SmallVectorImpl<ReturnInst *> &Returns,
245 const char *NameSuffix =
"", ClonedCodeInfo *CodeInfo =
nullptr,
246 ValueMapTypeRemapper *TypeMapper =
nullptr,
247 ValueMaterializer *Materializer =
nullptr,
252 const Instruction *StartingInst,
254 SmallVectorImpl<ReturnInst *> &Returns,
255 const char *NameSuffix, ClonedCodeInfo &CodeInfo);
271 SmallVectorImpl<ReturnInst *> &Returns,
272 const char *NameSuffix, ClonedCodeInfo &CodeInfo);
322 InlineFunctionInfo &IFI);
335 bool MergeAttributes =
false,
336 AAResults *CalleeAAR =
nullptr,
337 bool InsertLifetime =
true,
338 bool TrackInlineHistory =
false,
339 Function *ForwardVarArgsTo =
nullptr,
340 OptimizationRemarkEmitter *ORE =
nullptr);
365 bool MergeAttributes =
false,
366 AAResults *CalleeAAR =
nullptr,
367 bool InsertLifetime =
true,
368 bool TrackInlineHistory =
false,
369 Function *ForwardVarArgsTo =
nullptr,
370 OptimizationRemarkEmitter *ORE =
nullptr);
377 PGOContextualProfile &CtxProf,
378 bool MergeAttributes =
false,
379 AAResults *CalleeAAR =
nullptr,
380 bool InsertLifetime =
true,
381 bool TrackInlineHistory =
false,
382 Function *ForwardVarArgsTo =
nullptr,
383 OptimizationRemarkEmitter *ORE =
nullptr);
395 const Twine &NameSuffix, LoopInfo *LI,
397 SmallVectorImpl<BasicBlock *> &Blocks);
403 AssumptionCache *AC =
nullptr);
412 BasicBlock *BB, BasicBlock *PredBB, Instruction *StopAt,
419 Function *Callee, int64_t EntryDelta,
420 const ValueMap<const Value *, WeakTrackingVH> *VMap =
nullptr);
427 SmallVectorImpl<MDNode *> &NoAliasDeclScopes);
435 SmallVectorImpl<MDNode *> &NoAliasDeclScopes);
447 DenseMap<MDNode *, MDNode *> &ClonedScopes,
448 DenseMap<const MDNode *, MDNode *> &ClonedDomains,
449 StringRef Ext, LLVMContext &Context);
460 DenseMap<MDNode *, MDNode *> &ClonedScopes,
461 const DenseMap<const MDNode *, MDNode *> &ClonedDomains,
462 StringRef Ext, LLVMContext &Context);
469 LLVMContext &Context, StringRef Ext);
475 Instruction *IStart, Instruction *IEnd,
476 LLVMContext &Context, StringRef Ext);
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file defines the DenseSet and SmallDenseSet classes.
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...
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Value * ConvergenceControlToken
bool UpdateProfile
Update profile for callee as well as cloned version.
Instruction * CallSiteEHPad
function_ref< AssumptionCache &(Function &)> GetAssumptionCache
If non-null, InlineFunction will update the callgraph to reflect the changes it makes.
BlockFrequencyInfo * CalleeBFI
SmallVector< AllocaInst *, 4 > StaticAllocas
InlineFunction fills this in with all static allocas that get copied into the caller.
InlineFunctionInfo(function_ref< AssumptionCache &(Function &)> GetAssumptionCache=nullptr, ProfileSummaryInfo *PSI=nullptr, BlockFrequencyInfo *CallerBFI=nullptr, BlockFrequencyInfo *CalleeBFI=nullptr, bool UpdateProfile=true)
BlockFrequencyInfo * CallerBFI
SmallVector< CallBase *, 8 > InlinedCallSites
All of the new call sites inlined into the caller.
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.
Implements a dense probed hash-table based set with some number of buckets stored inline.
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
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 void CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc, ValueToValueMapTy &VMap, bool ModuleLevelChanges, SmallVectorImpl< ReturnInst * > &Returns, const char *NameSuffix, ClonedCodeInfo &CodeInfo)
This works exactly like CloneFunctionInto, except that it does some simple constant prop and DCE on t...
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 InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, bool MergeAttributes=false, AAResults *CalleeAAR=nullptr, bool InsertLifetime=true, bool TrackInlineHistory=false, Function *ForwardVarArgsTo=nullptr, OptimizationRemarkEmitter *ORE=nullptr)
This function inlines the called function into the basic block of the caller.
LLVM_ABI void remapInstructionsInBlocks(ArrayRef< BasicBlock * > Blocks, ValueToValueMapTy &VMap, AssumptionCache *AC=nullptr)
Remaps instructions in Blocks using the mapping in VMap.
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 cloneNoAliasScopes(ArrayRef< MDNode * > NoAliasDeclScopes, DenseMap< MDNode *, MDNode * > &ClonedScopes, DenseMap< const MDNode *, MDNode * > &ClonedDomains, 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 InlineFunctionImpl(CallBase &CB, InlineFunctionInfo &IFI, bool MergeAttributes=false, AAResults *CalleeAAR=nullptr, bool InsertLifetime=true, bool TrackInlineHistory=false, Function *ForwardVarArgsTo=nullptr, OptimizationRemarkEmitter *ORE=nullptr)
This should generally not be used, use InlineFunction instead.
LLVM_ABI void CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc, const Instruction *StartingInst, ValueToValueMapTy &VMap, bool ModuleLevelChanges, SmallVectorImpl< ReturnInst * > &Returns, const char *NameSuffix, ClonedCodeInfo &CodeInfo)
This works like CloneAndPruneFunctionInto, except that it does not clone the entire function.
LLVM_ABI void cloneAndAdaptNoAliasScopes(ArrayRef< MDNode * > NoAliasDeclScopes, ArrayRef< BasicBlock * > NewBlocks, LLVMContext &Context, StringRef Ext)
Clone the specified noalias decl scopes.
ArrayRef(const T &OneElt) -> ArrayRef< T >
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 adaptNoAliasScopes(llvm::Instruction *I, DenseMap< MDNode *, MDNode * > &ClonedScopes, const DenseMap< const MDNode *, MDNode * > &ClonedDomains, StringRef Ext, LLVMContext &Context)
Adapt the metadata for the specified instruction according to the provided mapping.
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.
@ End
Run the machine verifier once, at the end of the pipeline.
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.
bool removeOriginallyIndirectCall(const Value *V)
bool isOriginallyIndirectCall(const Value *V) const
bool isSimplified(const Value *From, const Value *To) const
bool ContainsCalls
This is set to true if the cloned code contains a normal call instruction.
SmallDenseSet< AssertingVH< const Value >, 4 > OriginallyIndirectCalls
bool ContainsMemProfMetadata
This is set to true if there is memprof related metadata (memprof or callsite metadata) in the cloned...
void replaceOriginallyIndirectCall(const Value *Old, const Value *New)
DenseMap< const Value *, const Value * > OrigVMap
Like VMap, but maps only unsimplified instructions.
std::vector< WeakTrackingVH > OperandBundleCallSites
All cloned call sites that have operand bundles attached are appended to this vector.