18 #ifndef LLVM_TRANSFORMS_UTILS_CLONING_H
19 #define LLVM_TRANSFORMS_UTILS_CLONING_H
47 class AssumptionCacheTracker;
100 const Twine &NameSuffix =
"", Function *
F =
nullptr,
101 ClonedCodeInfo *CodeInfo =
nullptr);
116 bool ModuleLevelChanges,
117 ClonedCodeInfo *CodeInfo =
nullptr);
130 SmallVectorImpl<ReturnInst*> &Returns,
131 const char *NameSuffix =
"",
132 ClonedCodeInfo *CodeInfo =
nullptr,
133 ValueMapTypeRemapper *TypeMapper =
nullptr,
134 ValueMaterializer *Materializer =
nullptr);
165 const Instruction *StartingInst,
167 SmallVectorImpl<ReturnInst*> &Returns,
168 const char *NameSuffix =
"",
169 ClonedCodeInfo *CodeInfo =
nullptr,
170 CloningDirector *Director =
nullptr);
186 SmallVectorImpl<ReturnInst*> &Returns,
187 const char *NameSuffix =
"",
188 ClonedCodeInfo *CodeInfo =
nullptr,
189 Instruction *TheCall =
nullptr);
231 bool InsertLifetime =
true);
233 bool InsertLifetime =
true);
235 bool InsertLifetime =
true);
244 const Twine &NameSuffix, LoopInfo *LI,
246 SmallVectorImpl<BasicBlock *> &Blocks);
void CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc, const Instruction *StartingInst, ValueToValueMapTy &VMap, bool ModuleLevelChanges, SmallVectorImpl< ReturnInst * > &Returns, const char *NameSuffix="", ClonedCodeInfo *CodeInfo=nullptr, CloningDirector *Director=nullptr)
This works like CloneAndPruneFunctionInto, except that it does not clone the entire function...
CallGraph * CG
CG - If non-null, InlineFunction will update the callgraph to reflect the changes it makes...
Module * CloneModule(const Module *M)
CloneModule - Return an exact copy of the specified module.
bool InlineFunction(CallInst *C, InlineFunctionInfo &IFI, bool InsertLifetime=true)
InlineFunction - This function inlines the called function into the basic block of the caller...
An immutable pass that tracks lazily created AssumptionCache objects.
InlineFunctionInfo - This class captures the data input to the InlineFunction call, and records the auxiliary results produced by it.
virtual ValueMaterializer * getValueMaterializer()
void remapInstructionsInBlocks(const SmallVectorImpl< BasicBlock * > &Blocks, ValueToValueMapTy &VMap)
Remaps instructions in Blocks using the mapping in VMap.
void CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc, ValueToValueMapTy &VMap, bool ModuleLevelChanges, SmallVectorImpl< ReturnInst * > &Returns, const char *NameSuffix="", ClonedCodeInfo *CodeInfo=nullptr, Instruction *TheCall=nullptr)
CloneAndPruneFunctionInto - This works exactly like CloneFunctionInto, except that it does some simpl...
void CloneFunctionInto(Function *NewFunc, const Function *OldFunc, ValueToValueMapTy &VMap, bool ModuleLevelChanges, 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...
virtual CloningAction handleInstruction(ValueToValueMapTy &VMap, const Instruction *Inst, BasicBlock *NewBB)=0
Subclasses must override this function to customize cloning behavior.
virtual ValueMapTypeRemapper * getTypeRemapper()
virtual ~CloningDirector()
A helper class used with CloneAndPruneIntoFromInst to change the default behavior while instructions ...
ValueMaterializer - This is a class that can be implemented by clients to materialize Values on deman...
LLVM Basic Block Representation.
Continue cloning the instruction (default behavior).
SmallVector< WeakVH, 8 > InlinedCalls
InlinedCalls - InlineFunction fills this in with callsites that were inlined from the callee...
AssumptionCacheTracker * ACT
ValueMap< const Value *, WeakVH > ValueToValueMapTy
InlineFunctionInfo(CallGraph *cg=nullptr, AliasAnalysis *AA=nullptr, AssumptionCacheTracker *ACT=nullptr)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Skip this instruction and stop cloning the current basic block.
Loop * cloneLoopWithPreheader(BasicBlock *Before, BasicBlock *LoopDomBB, Loop *OrigLoop, ValueToValueMapTy &VMap, const Twine &NameSuffix, LoopInfo *LI, DominatorTree *DT, SmallVectorImpl< BasicBlock * > &Blocks)
Clones a loop OrigLoop.
ValueMapTypeRemapper - This is a class that can be implemented by clients to remap types when cloning...
Don't clone the terminator but clone the current block's successors.
bool ContainsCalls
ContainsCalls - This is set to true if the cloned code contains a normal call instruction.
SmallVector< AllocaInst *, 4 > StaticAllocas
StaticAllocas - InlineFunction fills this in with all static allocas that get copied into the caller...
The basic data container for the call graph of a Module of IR.
ClonedCodeInfo - This struct can be used to capture information about code being cloned, while it is being cloned.
CloningAction
This enumeration describes the way CloneAndPruneIntoFromInst should proceed after the CloningDirector...
bool ContainsDynamicAllocas
ContainsDynamicAllocas - This is set to true if the cloned code contains a 'dynamic' alloca...
Function * CloneFunction(const Function *F, ValueToValueMapTy &VMap, bool ModuleLevelChanges, ClonedCodeInfo *CodeInfo=nullptr)
CloneFunction - Return a copy of the specified function, but without embedding the function into anot...
BasicBlock * CloneBasicBlock(const BasicBlock *BB, ValueToValueMapTy &VMap, const Twine &NameSuffix="", Function *F=nullptr, ClonedCodeInfo *CodeInfo=nullptr)
CloneBasicBlock - Return a copy of the specified basic block, but without embedding the block into a ...