[llvm-branch-commits] [llvm] f9ba347 - [SimplifyCFG] FoldValueComparisonIntoPredecessors(): don't insert a DomTree edge if it already exists
Roman Lebedev via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jan 11 15:14:51 PST 2021
Author: Roman Lebedev
Date: 2021-01-12T02:09:47+03:00
New Revision: f9ba34770638389ee9b251f6ab801c7411601c77
URL: https://github.com/llvm/llvm-project/commit/f9ba34770638389ee9b251f6ab801c7411601c77
DIFF: https://github.com/llvm/llvm-project/commit/f9ba34770638389ee9b251f6ab801c7411601c77.diff
LOG: [SimplifyCFG] FoldValueComparisonIntoPredecessors(): don't insert a DomTree edge if it already exists
When we are adding edges to the terminator and potentially turning it
into a switch (if it wasn't already), it is possible that the
case we're adding will share it's destination with one of the
preexisting cases, in which case there is no domtree edge to add.
Indeed, this change does not have a test coverage change.
This failure has been exposed in an existing test coverage
by a follow-up patch that switches to lazy domtreeupdater mode,
and removes domtree verification from
SimplifyCFGOpt::simplifyOnce()/SimplifyCFGOpt::run(),
IOW it does not appear feasible to add dedicated test coverage here.
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 7158133f177a..880d0e7e6e13 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1267,7 +1267,8 @@ bool SimplifyCFGOpt::FoldValueComparisonIntoPredecessors(Instruction *TI,
(void)I;
AddPredecessorToBlock(NewSuccessor.first, Pred, BB);
}
- Updates.push_back({DominatorTree::Insert, Pred, NewSuccessor.first});
+ if (!is_contained(successors(Pred), NewSuccessor.first))
+ Updates.push_back({DominatorTree::Insert, Pred, NewSuccessor.first});
}
Builder.SetInsertPoint(PTI);
More information about the llvm-branch-commits
mailing list