[llvm] [BasicBlockUtils] Fix SplitBlockPredecessors incorrect dominator insert (PR #107190)
Joshua Cao via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 4 00:23:04 PDT 2024
================
@@ -1160,7 +1160,10 @@ static void UpdateAnalysisInformation(BasicBlock *OldBB, BasicBlock *NewBB,
// Split block expects NewBB to have a non-empty set of predecessors.
SmallVector<DominatorTree::UpdateType, 8> Updates;
SmallPtrSet<BasicBlock *, 8> UniquePreds;
- Updates.push_back({DominatorTree::Insert, NewBB, OldBB});
+ if (OldBB->getSinglePredecessor()) {
+ assert(OldBB->getSinglePredecessor() == NewBB);
+ Updates.push_back({DominatorTree::Insert, NewBB, OldBB});
+ }
----------------
caojoshua wrote:
Yes, we do always update a CFG edge. But that might not be a **dominating** edge. In the example above (`bb2` is `OldBB`):
```
bb0:
br label %new_bb
new_bb:
br label %bb2
bb1:
br label %bb2
bb2: ...
```
Without this patch, this would have added a edge from `new_bb` to `bb2`. But `new_bb` does not actually dominate `bb2`, since we can reach `bb2` from another path `bb1`
https://github.com/llvm/llvm-project/pull/107190
More information about the llvm-commits
mailing list