[llvm] 7600d7c - [SimplifyCFG] removeUnreachableBlocks(): switch to non-permissive DomTree updates

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 7 15:16:16 PST 2021


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))


        


More information about the llvm-commits mailing list