Go to the documentation of this file.
17 #ifndef LLVM_TRANSFORMS_UTILS_CLONING_H
18 #define LLVM_TRANSFORMS_UTILS_CLONING_H
35 class BlockFrequencyInfo;
37 class DebugInfoFinder;
44 class ProfileSummaryInfo;
56 std::unique_ptr<Module>
58 function_ref<
bool(
const GlobalValue *)> ShouldCloneDefinition);
116 const Twine &NameSuffix =
"", Function *
F =
nullptr,
117 ClonedCodeInfo *CodeInfo =
nullptr,
118 DebugInfoFinder *DIFinder =
nullptr);
132 ClonedCodeInfo *CodeInfo =
nullptr);
167 SmallVectorImpl<ReturnInst *> &Returns,
168 const char *NameSuffix =
"",
169 ClonedCodeInfo *CodeInfo =
nullptr,
170 ValueMapTypeRemapper *TypeMapper =
nullptr,
171 ValueMaterializer *Materializer =
nullptr);
174 const Instruction *StartingInst,
176 SmallVectorImpl<ReturnInst *> &Returns,
177 const char *NameSuffix =
"",
178 ClonedCodeInfo *CodeInfo =
nullptr);
193 SmallVectorImpl<ReturnInst*> &Returns,
194 const char *NameSuffix =
"",
195 ClonedCodeInfo *CodeInfo =
nullptr);
263 InlineResult
InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
264 AAResults *CalleeAAR =
nullptr,
265 bool InsertLifetime =
true,
266 Function *ForwardVarArgsTo =
nullptr);
276 const Twine &NameSuffix, LoopInfo *LI,
278 SmallVectorImpl<BasicBlock *> &Blocks);
294 DomTreeUpdater &DTU);
300 Function *Callee, int64_t EntryDelta,
301 const ValueMap<const Value *, WeakTrackingVH> *VMap =
nullptr);
307 ArrayRef<BasicBlock *> BBs, SmallVectorImpl<MDNode *> &NoAliasDeclScopes);
314 SmallVectorImpl<MDNode *> &NoAliasDeclScopes);
322 ArrayRef<MDNode *> NoAliasDeclScopes,
323 DenseMap<MDNode *, MDNode *> &ClonedScopes,
337 ArrayRef<BasicBlock *> NewBlocks,
344 Instruction *IStart, Instruction *IEnd,
348 #endif // LLVM_TRANSFORMS_UTILS_CLONING_H
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
This struct can be used to capture information about code being cloned, while it is being cloned.
InstListType::iterator iterator
Instruction iterators...
Loop * cloneLoopWithPreheader(BasicBlock *Before, BasicBlock *LoopDomBB, Loop *OrigLoop, ValueToValueMapTy &VMap, const Twine &NameSuffix, LoopInfo *LI, DominatorTree *DT, SmallVectorImpl< BasicBlock * > &Blocks)
Clones a loop OrigLoop.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
The basic data container for the call graph of a Module of IR.
InlineFunctionInfo(CallGraph *cg=nullptr, function_ref< AssumptionCache &(Function &)> GetAssumptionCache=nullptr, ProfileSummaryInfo *PSI=nullptr, BlockFrequencyInfo *CallerBFI=nullptr, BlockFrequencyInfo *CalleeBFI=nullptr, bool UpdateProfile=true)
BlockFrequencyInfo * CallerBFI
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
CallGraph * CG
If non-null, InlineFunction will update the callgraph to reflect the changes it makes.
void remapInstructionsInBlocks(const SmallVectorImpl< BasicBlock * > &Blocks, ValueToValueMapTy &VMap)
Remaps instructions in Blocks using the mapping in VMap.
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...
std::vector< WeakTrackingVH > OperandBundleCallSites
All cloned call sites that have operand bundles attached are appended to this vector.
bool isSimplified(const Value *From, const Value *To) const
Analysis providing profile information.
An efficient, type-erasing, non-owning reference to a callable.
void cloneAndAdaptNoAliasScopes(ArrayRef< MDNode * > NoAliasDeclScopes, ArrayRef< BasicBlock * > NewBlocks, LLVMContext &Context, StringRef Ext)
Clone the specified noalias decl scopes.
BasicBlock * CloneBasicBlock(const BasicBlock *BB, ValueToValueMapTy &VMap, const Twine &NameSuffix="", Function *F=nullptr, ClonedCodeInfo *CodeInfo=nullptr, DebugInfoFinder *DIFinder=nullptr)
Return a copy of the specified basic block, but without embedding the block into a particular functio...
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...
SmallVector< WeakTrackingVH, 8 > InlinedCalls
InlineFunction fills this in with callsites that were inlined from the callee.
void adaptNoAliasScopes(llvm::Instruction *I, const DenseMap< MDNode *, MDNode * > &ClonedScopes, LLVMContext &Context)
Adapt the metadata for the specified instruction according to the provided mapping.
ValueMap< const Value *, WeakTrackingVH > ValueToValueMapTy
void cloneNoAliasScopes(ArrayRef< MDNode * > NoAliasDeclScopes, DenseMap< MDNode *, MDNode * > &ClonedScopes, StringRef Ext, LLVMContext &Context)
Duplicate the specified list of noalias decl scopes.
@ BasicBlock
Various leaf nodes.
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...
DenseMap< const Value *, const Value * > OrigVMap
Like VMap, but maps only unsimplified instructions.
void identifyNoAliasScopesToClone(ArrayRef< BasicBlock * > BBs, SmallVectorImpl< MDNode * > &NoAliasDeclScopes)
Find the 'llvm.experimental.noalias.scope.decl' intrinsics in the specified basic blocks and extract ...
A cache of @llvm.assume calls within a function.
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.
Machine Check Debug Module
Function * CloneFunction(Function *F, ValueToValueMapTy &VMap, ClonedCodeInfo *CodeInfo=nullptr)
Return a copy of the specified function and add it to that function's module.
bool ContainsCalls
This is set to true if the cloned code contains a normal call instruction.
SmallVector< CallBase *, 8 > InlinedCallSites
All of the new call sites inlined into the caller.
This class captures the data input to the InlineFunction call, and records the auxiliary results prod...
SmallVector< AllocaInst *, 4 > StaticAllocas
InlineFunction fills this in with all static allocas that get copied into the caller.
bool UpdateProfile
Update profile for callee as well as cloned version.
std::unique_ptr< Module > CloneModule(const Module &M)
Return an exact copy of the specified module.
InlineResult InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, AAResults *CalleeAAR=nullptr, bool InsertLifetime=true, Function *ForwardVarArgsTo=nullptr)
This function inlines the called function into the basic block of the caller.
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.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
BlockVerifier::State From
function_ref< AssumptionCache &(Function &)> GetAssumptionCache
bool ContainsDynamicAllocas
This is set to true if the cloned code contains a 'dynamic' alloca.
BlockFrequencyInfo * CalleeBFI
LLVM Value Representation.