aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2021-05-19 12:48:40 +0300
committerRoman Lebedev <lebedev.ri@gmail.com>2021-05-19 14:08:25 +0300
commitbb5d613aba347c3ab3fcbf1507c22d2301f5b47d (patch)
tree27e86152ef2c0568fd13d27fd1ede28b435e7a3f /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parenta0be08164622bf938855ff5d19dd8e9d0c96b9b3 (diff)
downloadllvm-bb5d613aba347c3ab3fcbf1507c22d2301f5b47d.zip
llvm-bb5d613aba347c3ab3fcbf1507c22d2301f5b47d.tar.gz
llvm-bb5d613aba347c3ab3fcbf1507c22d2301f5b47d.tar.bz2
[NFCI][SimplifyCFG] removeEmptyCleanup(): streamline PHI node updating
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp21
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);
}
}