Clone OldFunc into NewFunc with on‐the‐fly constant prop and DCE.
Synopsis
Declared in <llvm/Transforms/Utils/Cloning.h>
void
CloneAndPruneFunctionInto(
Function* NewFunc,
Function const* OldFunc,
ValueToValueMapTy& VMap,
bool ModuleLevelChanges,
SmallVectorImpl<ReturnInst*>& Returns,
char const* NameSuffix,
ClonedCodeInfo& CodeInfo);
Description
This works exactly like CloneFunctionInto, except that it does some simple constant prop and DCE on the fly. The effect of this is to copy significantly less code in cases where (for example) a function call with constant arguments is inlined, and those constant arguments cause a significant amount of code in the callee to be dead. Since this doesn't produce an exactly copy of the input, it can't be used for things like CloneFunction or CloneModule.
If ModuleLevelChanges is false, VMap contains no non‐identity GlobalValue mappings.
Parameters
Name |
Description |
NewFunc |
Destination function that receives the pruned clone. |
OldFunc |
Source function to clone from. |
VMap |
Mapping from old values to new ones; updated during cloning. |
ModuleLevelChanges |
Whether module‐level value remapping is allowed. |
Returns |
Filled with return instructions from the cloned body. |
NameSuffix |
Suffix appended to cloned value names. |
CodeInfo |
Collector for statistics about the cloned code. |
Created with MrDocs