ΒΆllvm::BasicBlock* CloneBasicBlock(
    const llvm::BasicBlock* BB,
    llvm::ValueToValueMapTy& VMap,
    const llvm::Twine& NameSuffix = "",
    llvm::Function* F = nullptr,
    llvm::ClonedCodeInfo* CodeInfo = nullptr,
    llvm::DebugInfoFinder* DIFinder = nullptr)

Description

Return a copy of the specified basic block, but without embedding the block into a particular function. The block returned is an exact copy of the specified basic block, without any remapping having been performed. Because of this, this is only suitable for applications where the basic block will be inserted into the same function that it was cloned from (loop unrolling would use this, for example). Also, note that this function makes a direct copy of the basic block, and can thus produce illegal LLVM code. In particular, it will copy any PHI nodes from the original block, even though there are no predecessors for the newly cloned block (thus, phi nodes will have to be updated). Also, this block will branch to the old successors of the original block: these successors will have to have any PHI nodes updated to account for the new incoming edges. The correlation between instructions in the source and result basic blocks is recorded in the VMap map. If you have a particular suffix you'd like to use to add to any cloned names, specify it as the optional third parameter. If you would like the basic block to be auto-inserted into the end of a function, you can specify it as the optional fourth parameter. If you would like to collect additional information about the cloned function, you can specify a ClonedCodeInfo object with the optional fifth parameter.

Declared at: llvm/include/llvm/Transforms/Utils/Cloning.h:115

Parameters

const llvm::BasicBlock* BB
llvm::ValueToValueMapTy& VMap
const llvm::Twine& NameSuffix = ""
llvm::Function* F = nullptr
llvm::ClonedCodeInfo* CodeInfo = nullptr
llvm::DebugInfoFinder* DIFinder = nullptr