ΒΆvoid CloneFunctionInto(
llvm::Function* NewFunc,
const llvm::Function* OldFunc,
llvm::ValueToValueMapTy& VMap,
llvm::CloneFunctionChangeType Changes,
SmallVectorImpl<llvm::ReturnInst*>& Returns,
const char* NameSuffix = "",
llvm::ClonedCodeInfo* CodeInfo = nullptr,
llvm::ValueMapTypeRemapper* TypeMapper =
nullptr,
llvm::ValueMaterializer* Materializer =
nullptr)
void CloneFunctionInto(
llvm::Function* NewFunc,
const llvm::Function* OldFunc,
llvm::ValueToValueMapTy& VMap,
llvm::CloneFunctionChangeType Changes,
SmallVectorImpl<llvm::ReturnInst*>& Returns,
const char* NameSuffix = "",
llvm::ClonedCodeInfo* CodeInfo = nullptr,
llvm::ValueMapTypeRemapper* TypeMapper =
nullptr,
llvm::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 \p Changes is \a CloneFunctionChangeType::LocalChangesOnly, VMap is required to contain no non-identity GlobalValue mappings. Otherwise, referenced metadata will be cloned. If \p Changes is less than \a CloneFunctionChangeType::DifferentModule indicating cloning into the same module (even if it's LocalChangesOnly), if debug info metadata transitively references a \a DISubprogram, it will be cloned, effectively upgrading \p Changes to GlobalChanges while suppressing cloning of types and compile units. If \p Changes is \a CloneFunctionChangeType::DifferentModule, the new module's \c !llvm.dbg.cu will get updated with any newly created compile units. (\a CloneFunctionChangeType::ClonedModule leaves that work for the caller.) FIXME: Consider simplifying this function by splitting out \a CloneFunctionMetadataInto() and expecting / updating callers to call it first when / how it's needed.
Declared at: llvm/include/llvm/Transforms/Utils/Cloning.h:165
Parameters
- llvm::Function* NewFunc
- const llvm::Function* OldFunc
- llvm::ValueToValueMapTy& VMap
- llvm::CloneFunctionChangeType Changes
- SmallVectorImpl<llvm::ReturnInst*>& Returns
- const char* NameSuffix = ""
- llvm::ClonedCodeInfo* CodeInfo = nullptr
- llvm::ValueMapTypeRemapper* TypeMapper = nullptr
- llvm::ValueMaterializer* Materializer = nullptr