[llvm] [BasicBlockUtils] Fix SplitBlockPredecessors incorrect dominator insert (PR #107190)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 4 00:26:46 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});
+      }
----------------
nikic wrote:

DTU updates are about edges in the CFG, not the DT. The point of DTU is to determine the correct DT updates from CFG updates, so this kind of reasoning in the caller should never be necessary.

https://github.com/llvm/llvm-project/pull/107190


More information about the llvm-commits mailing list