Author: Roman Lebedev
Date: 2021-01-08T02:15:26+03:00
New Revision: 7600d7c7be07ee78543522d0fbd1e92e672a0327

URL: 
https://github.com/llvm/llvm-project/commit/7600d7c7be07ee78543522d0fbd1e92e672a0327
DIFF: 
https://github.com/llvm/llvm-project/commit/7600d7c7be07ee78543522d0fbd1e92e672a0327.diff

LOG: [SimplifyCFG] removeUnreachableBlocks(): switch to non-permissive DomTree 
updates

... which requires not deleting edges that were just deleted already,
    by not processing the same predecessor more than once.

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/Local.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/Local.cpp 
b/llvm/lib/Transforms/Utils/Local.cpp
index 7c962edba3ca..220a4d43b491 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -2376,12 +2376,16 @@ bool llvm::removeUnreachableBlocks(Function &F, 
DomTreeUpdater *DTU,
   // their internal references. Update DTU if available.
   std::vector<DominatorTree::UpdateType> Updates;
   for (auto *BB : DeadBlockSet) {
+    SmallSetVector<BasicBlock *, 8> UniqueSuccessors;
     for (BasicBlock *Successor : successors(BB)) {
       if (!DeadBlockSet.count(Successor))
         Successor->removePredecessor(BB);
       if (DTU)
-        Updates.push_back({DominatorTree::Delete, BB, Successor});
+        UniqueSuccessors.insert(Successor);
     }
+    if (DTU)
+      for (auto *UniqueSuccessor : UniqueSuccessors)
+        Updates.push_back({DominatorTree::Delete, BB, UniqueSuccessor});
     BB->dropAllReferences();
     if (DTU) {
       Instruction *TI = BB->getTerminator();
@@ -2398,7 +2402,7 @@ bool llvm::removeUnreachableBlocks(Function &F, 
DomTreeUpdater *DTU,
   }
 
   if (DTU) {
-    DTU->applyUpdatesPermissive(Updates);
+    DTU->applyUpdates(Updates);
     bool Deleted = false;
     for (auto *BB : DeadBlockSet) {
       if (DTU->isBBPendingDeletion(BB))


        
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to