[llvm] bb5d613 - [NFCI][SimplifyCFG] removeEmptyCleanup(): streamline PHI node updating
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Wed May 19 04:09:01 PDT 2021
Author: Roman Lebedev
Date: 2021-05-19T14:08:25+03:00
New Revision: bb5d613aba347c3ab3fcbf1507c22d2301f5b47d
URL: https://github.com/llvm/llvm-project/commit/bb5d613aba347c3ab3fcbf1507c22d2301f5b47d
DIFF: https://github.com/llvm/llvm-project/commit/bb5d613aba347c3ab3fcbf1507c22d2301f5b47d.diff
LOG: [NFCI][SimplifyCFG] removeEmptyCleanup(): streamline PHI node updating
Added:
Modified:
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index ffbf4e8ccc12..b0e5e532c12f 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);
}
}
More information about the llvm-commits
mailing list