diff options
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index ffbf4e8..b0e5e53 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -4489,22 +4489,11 @@ static bool removeEmptyCleanup(CleanupReturnInst *RI, DomTreeUpdater *DTU) { // Remove the entry for the block we are deleting. DestPN.removeIncomingValue(Idx, false); - if (SrcPN && SrcPN->getParent() == BB) { - // If the incoming value was a PHI node in the cleanup pad we are - // removing, we need to merge that PHI node's incoming values into - // DestPN. - for (unsigned SrcIdx = 0, SrcE = SrcPN->getNumIncomingValues(); - SrcIdx != SrcE; ++SrcIdx) { - DestPN.addIncoming(SrcPN->getIncomingValue(SrcIdx), - SrcPN->getIncomingBlock(SrcIdx)); - } - } else { - // Otherwise, the incoming value came from above BB and - // so we can just reuse it. We must associate all of BB's - // predecessors with this value. - for (auto *pred : predecessors(BB)) { - DestPN.addIncoming(SrcVal, pred); - } + bool NeedPHITranslation = SrcPN && SrcPN->getParent() == BB; + for (auto *Pred : predecessors(BB)) { + Value *Incoming = + NeedPHITranslation ? SrcPN->getIncomingValueForBlock(Pred) : SrcVal; + DestPN.addIncoming(Incoming, Pred); } } |