Skip to content

Commit bb5d613

Browse files
committed
[NFCI][SimplifyCFG] removeEmptyCleanup(): streamline PHI node updating
1 parent a0be081 commit bb5d613

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4489,22 +4489,11 @@ static bool removeEmptyCleanup(CleanupReturnInst *RI, DomTreeUpdater *DTU) {
44894489
// Remove the entry for the block we are deleting.
44904490
DestPN.removeIncomingValue(Idx, false);
44914491

4492-
if (SrcPN && SrcPN->getParent() == BB) {
4493-
// If the incoming value was a PHI node in the cleanup pad we are
4494-
// removing, we need to merge that PHI node's incoming values into
4495-
// DestPN.
4496-
for (unsigned SrcIdx = 0, SrcE = SrcPN->getNumIncomingValues();
4497-
SrcIdx != SrcE; ++SrcIdx) {
4498-
DestPN.addIncoming(SrcPN->getIncomingValue(SrcIdx),
4499-
SrcPN->getIncomingBlock(SrcIdx));
4500-
}
4501-
} else {
4502-
// Otherwise, the incoming value came from above BB and
4503-
// so we can just reuse it. We must associate all of BB's
4504-
// predecessors with this value.
4505-
for (auto *pred : predecessors(BB)) {
4506-
DestPN.addIncoming(SrcVal, pred);
4507-
}
4492+
bool NeedPHITranslation = SrcPN && SrcPN->getParent() == BB;
4493+
for (auto *Pred : predecessors(BB)) {
4494+
Value *Incoming =
4495+
NeedPHITranslation ? SrcPN->getIncomingValueForBlock(Pred) : SrcVal;
4496+
DestPN.addIncoming(Incoming, Pred);
45084497
}
45094498
}
45104499

0 commit comments

Comments
 (0)