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.
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);
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.
| Name | Description |
|---|---|
| Returns | This class consists of common code factored out of the SmallVector class to reduce code duplication based on the SmallVector 'N' template parameter. |
| CodeInfo | This struct can be used to capture information about code being cloned, while it is being cloned. |
| TypeMapper | This is a class that can be implemented by clients to remap types when cloning constants and instructions. |
| Materializer | This is a class that can be implemented by clients to materialize Values on demand. |