Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions llvm/include/llvm/Transforms/Utils/Cloning.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ struct ClonedCodeInfo {
/// parameter.
BasicBlock *CloneBasicBlock(const BasicBlock *BB, ValueToValueMapTy &VMap,
const Twine &NameSuffix = "", Function *F = nullptr,
ClonedCodeInfo *CodeInfo = nullptr,
DebugInfoFinder *DIFinder = nullptr);
ClonedCodeInfo *CodeInfo = nullptr);

/// Return a copy of the specified function and add it to that
/// function's module. Also, any references specified in the VMap are changed
Expand Down
12 changes: 2 additions & 10 deletions llvm/lib/Transforms/Utils/CloneFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,16 @@ using namespace llvm;
/// See comments in Cloning.h.
BasicBlock *llvm::CloneBasicBlock(const BasicBlock *BB, ValueToValueMapTy &VMap,
const Twine &NameSuffix, Function *F,
ClonedCodeInfo *CodeInfo,
DebugInfoFinder *DIFinder) {
ClonedCodeInfo *CodeInfo) {
BasicBlock *NewBB = BasicBlock::Create(BB->getContext(), "", F);
NewBB->IsNewDbgInfoFormat = BB->IsNewDbgInfoFormat;
if (BB->hasName())
NewBB->setName(BB->getName() + NameSuffix);

bool hasCalls = false, hasDynamicAllocas = false, hasMemProfMetadata = false;
Module *TheModule = F ? F->getParent() : nullptr;

// Loop over all instructions, and copy them over.
for (const Instruction &I : *BB) {
if (DIFinder && TheModule)
DIFinder->processInstruction(*TheModule, I);

Instruction *NewInst = I.clone();
if (I.hasName())
NewInst->setName(I.getName() + NameSuffix);
Expand Down Expand Up @@ -221,10 +216,7 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
for (const BasicBlock &BB : *OldFunc) {

// Create a new basic block and copy instructions into it!
// NOTE: don't pass DIFinder because instructions' debug info was processed
// in ProcessSubprogramAttachment. This will be cleaned up further.
BasicBlock *CBB =
CloneBasicBlock(&BB, VMap, NameSuffix, NewFunc, CodeInfo, nullptr);
BasicBlock *CBB = CloneBasicBlock(&BB, VMap, NameSuffix, NewFunc, CodeInfo);

// Add basic block mapping.
VMap[&BB] = CBB;
Expand Down
Loading