18 #ifndef LLVM_TRANSFORMS_UTILS_CLONING_H 19 #define LLVM_TRANSFORMS_UTILS_CLONING_H 37 class BlockFrequencyInfo;
40 class DebugInfoFinder;
48 class ProfileSummaryInfo;
53 std::unique_ptr<Module>
CloneModule(
const Module &M);
60 std::unique_ptr<Module>
62 function_ref<
bool(
const GlobalValue *)> ShouldCloneDefinition);
142 const char *NameSuffix =
"",
151 const char *NameSuffix =
"",
168 const char *NameSuffix =
"",
178 *GetAssumptionCache =
nullptr,
182 : CG(cg), GetAssumptionCache(GetAssumptionCache), PSI(PSI),
183 CallerBFI(CallerBFI), CalleeBFI(CalleeBFI) {}
208 StaticAllocas.
clear();
209 InlinedCalls.
clear();
210 InlinedCallSites.
clear();
235 bool InsertLifetime =
true);
238 bool InsertLifetime =
true);
241 bool InsertLifetime =
true,
242 Function *ForwardVarArgsTo =
nullptr);
274 #endif // LLVM_TRANSFORMS_UTILS_CLONING_H
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...
This class represents lattice values for constants.
CallGraph * CG
If non-null, InlineFunction will update the callgraph to reflect the changes it makes.
std::function< AssumptionCache &(Function &)> * GetAssumptionCache
Analysis providing profile information.
This class represents a function call, abstracting a target machine's calling convention.
Function * CloneFunction(Function *F, ValueToValueMapTy &VMap, ClonedCodeInfo *CodeInfo=nullptr)
Return a copy of the specified function and add it to that function's module.
A cache of @llvm.assume calls within a function.
InlineResult InlineFunction(CallInst *C, InlineFunctionInfo &IFI, AAResults *CalleeAAR=nullptr, bool InsertLifetime=true)
This function inlines the called function into the basic block of the caller.
This class captures the data input to the InlineFunction call, and records the auxiliary results prod...
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...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Utility to find all debug info in a module.
void CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc, ValueToValueMapTy &VMap, bool ModuleLevelChanges, SmallVectorImpl< ReturnInst *> &Returns, const char *NameSuffix="", ClonedCodeInfo *CodeInfo=nullptr, Instruction *TheCall=nullptr)
This works exactly like CloneFunctionInto, except that it does some simple constant prop and DCE on t...
std::vector< WeakTrackingVH > OperandBundleCallSites
All cloned call sites that have operand bundles attached are appended to this vector.
InlineResult is basically true or false.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
std::unique_ptr< Module > CloneModule(const Module &M)
Return an exact copy of the specified module.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
This is a class that can be implemented by clients to materialize Values on demand.
SmallVector< CallSite, 8 > InlinedCallSites
All of the new call sites inlined into the caller.
ValueMap< const Value *, WeakTrackingVH > ValueToValueMapTy
LLVM Basic Block Representation.
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...
InlineFunctionInfo(CallGraph *cg=nullptr, std::function< AssumptionCache &(Function &)> *GetAssumptionCache=nullptr, ProfileSummaryInfo *PSI=nullptr, BlockFrequencyInfo *CallerBFI=nullptr, BlockFrequencyInfo *CalleeBFI=nullptr)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
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...
This is a class that can be implemented by clients to remap types when cloning constants and instruct...
bool ContainsCalls
This is set to true if the cloned code contains a normal call instruction.
SmallVector< AllocaInst *, 4 > 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.
SmallVector< WeakTrackingVH, 8 > InlinedCalls
InlineFunction fills this in with callsites that were inlined from the callee.
Represents a single loop in the control flow graph.
This struct can be used to capture information about code being cloned, while it is being cloned...
Helper struct that represents how a value is mapped through different register banks.
BlockFrequencyInfo * CallerBFI
bool ContainsDynamicAllocas
This is set to true if the cloned code contains a 'dynamic' alloca.
Loop * cloneLoopWithPreheader(BasicBlock *Before, BasicBlock *LoopDomBB, Loop *OrigLoop, ValueToValueMapTy &VMap, const Twine &NameSuffix, LoopInfo *LI, DominatorTree *DT, SmallVectorImpl< BasicBlock *> &Blocks)
Clones a loop OrigLoop.
print Print MemDeps of function
void remapInstructionsInBlocks(const SmallVectorImpl< BasicBlock *> &Blocks, ValueToValueMapTy &VMap)
Remaps instructions in Blocks using the mapping in VMap.