Skip to content

Commit

Permalink
[NFC][DebugInfo][RemoveDIs] Use iterators to insert in callsite-split…
Browse files Browse the repository at this point in the history
…ting (#74455)

This patch gets call site splitting to use iterators for insertion
rather than instruction pointers. When we switch on non-instr debug-info
this becomes significant, as the iterators are going to signal whether
or not a position is before or after debug-info.

NFC as this isn't going to affect the output of any existing test.
  • Loading branch information
jmorse committed Dec 5, 2023
1 parent 953ac95 commit 34cdc91
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,10 @@ static void splitCallSite(CallBase &CB,
return;
}

auto *OriginalBegin = &*TailBB->begin();
BasicBlock::iterator OriginalBegin = TailBB->begin();
// Replace users of the original call with a PHI mering call-sites split.
if (CallPN) {
CallPN->insertBefore(OriginalBegin);
CallPN->insertBefore(*TailBB, OriginalBegin);
CB.replaceAllUsesWith(CallPN);
}

Expand All @@ -399,13 +399,13 @@ static void splitCallSite(CallBase &CB,
for (auto &Mapping : ValueToValueMaps)
NewPN->addIncoming(Mapping[CurrentI],
cast<Instruction>(Mapping[CurrentI])->getParent());
NewPN->insertBefore(&*TailBB->begin());
NewPN->insertBefore(*TailBB, TailBB->begin());
CurrentI->replaceAllUsesWith(NewPN);
}
CurrentI->dropDbgValues();
CurrentI->eraseFromParent();
// We are done once we handled the first original instruction in TailBB.
if (CurrentI == OriginalBegin)
if (CurrentI == &*OriginalBegin)
break;
}
}
Expand Down

0 comments on commit 34cdc91

Please sign in to comment.