Skip to content

Commit b51c450

Browse files
committed
Use BasicBlock::splice
1 parent 3e699ae commit b51c450

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -703,15 +703,12 @@ Error OpenMPIRBuilder::FinalizationInfo::mergeFiniBB(IRBuilderBase &Builder,
703703
}
704704

705705
// Move instructions from FiniBB to the start of OtherFiniBB.
706-
auto InsertAfter = OtherFiniBB->getFirstNonPHIIt();
707-
for (Instruction &I : make_early_inc_range(*FiniBB)) {
708-
if (I.isTerminator()) {
709-
I.eraseFromParent();
710-
break;
711-
}
712-
I.insertAfter(InsertAfter);
713-
InsertAfter = BasicBlock::iterator(&I);
714-
}
706+
auto EndIt = FiniBB->end();
707+
if (FiniBB->size() >= 1)
708+
if (auto Prev = std::prev(EndIt); Prev->isTerminator())
709+
EndIt = Prev;
710+
OtherFiniBB->splice(OtherFiniBB->getFirstNonPHIIt(), FiniBB, FiniBB->begin(),
711+
EndIt);
715712

716713
// Replace FiniBB with OtherFiniBB.
717714
for (User *U : make_early_inc_range(FiniBB->users())) {

0 commit comments

Comments
 (0)