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

Joshua Cao via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 4 00:32:43 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:

OK, didn't know that about DTU. Actually just tested this and even if I comment out the if statement, it still passes the unit tests. However, if I use the built clang to compile anything, it runs into assertions in LICM. I'll look into it.

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


More information about the llvm-commits mailing list