Clone OldFunc into NewFunc using the provided value map.
Synopsis
Declared in <llvm/Transforms/Utils/Cloning.h>
void
CloneFunctionInto(
Function* NewFunc,
Function const* OldFunc,
ValueToValueMapTy& VMap,
CloneFunctionChangeType Changes,
SmallVectorImpl<ReturnInst*>& Returns,
char const* NameSuffix = "",
ClonedCodeInfo* CodeInfo = nullptr,
ValueMapTypeRemapper* TypeMapper = nullptr,
ValueMaterializer* Materializer = nullptr);
Description
Clone OldFunc into NewFunc, transforming the old arguments into references to VMap values. Note that if NewFunc already has basic blocks, the ones cloned into it will be added to the end of the function. This function fills in a list of return instructions, and can optionally remap types and/or append the specified suffix to all values cloned.
If Changes is CloneFunctionChangeType::LocalChangesOnly, VMap is required to contain no non‐identity GlobalValue mappings. Otherwise, referenced metadata will be cloned.
If Changes is less than CloneFunctionChangeType::DifferentModule indicating cloning into the same module (even if it's LocalChangesOnly), if debug info metadata transitively references a DISubprogram, it will be cloned, effectively upgrading Changes to GlobalChanges while suppressing cloning of types and compile units.
If Changes is CloneFunctionChangeType::DifferentModule, the new module's !llvm.dbg.cu will get updated with any newly created compile units. (CloneFunctionChangeType::ClonedModule leaves that work for the caller.)
FIXME: Consider simplifying this function by splitting out CloneFunctionMetadataInto() and expecting / updating callers to call it first when / how it's needed.
Parameters
Name |
Description |
NewFunc |
Destination function that receives the cloned body. |
OldFunc |
Source function to clone from. |
VMap |
Mapping from old values (including arguments) to new ones. |
Changes |
How aggressively to clone metadata and update module state. |
Returns |
Filled with return instructions from the cloned body. |
NameSuffix |
Optional suffix appended to cloned value names. |
CodeInfo |
Optional collector for statistics about the cloned code. |
TypeMapper |
Optional remapper for types encountered while cloning. |
Materializer |
Optional materializer for values missing from |
Created with MrDocs