]> granicus.if.org Git - llvm/commitdiff
[Dominators] Delete UpdateLevelsAfterInsertion in edge insertion of depth-based searc...
authorFangrui Song <maskray@google.com>
Wed, 20 Feb 2019 02:35:24 +0000 (02:35 +0000)
committerFangrui Song <maskray@google.com>
Wed, 20 Feb 2019 02:35:24 +0000 (02:35 +0000)
Summary:
After insertion of (From, To), v is affected iff
depth(NCD)+1 < depth(v) && path P from To to v exists where every w on P s.t. depth(v) <= depth(w)

All affected vertices change their idom to NCD.

If a vertex u has changed its depth, it must be a descendant of an
affected vertex v. Its depth must have been updated by UpdateLevel()
called by setIDom() of the first affected ancestor.

So UpdateLevelsAfterInsertion and its bookkeeping variable VisitedNotAffectedQueue are redundant.
Run them only in debug builds as a sanity check.

Reviewers: kuhar

Reviewed By: kuhar

Subscribers: kristina, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D58369

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354429 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/GenericDomTreeConstruction.h

index 1a5712408a747115dad33df8943974e578cae35a..7ba907e94e26a77754009979f0b9a3911a02c172 100644 (file)
@@ -632,7 +632,9 @@ struct SemiNCAInfo {
         Bucket;
     SmallDenseSet<TreeNodePtr, 8> Visited;
     SmallVector<TreeNodePtr, 8> Affected;
-    SmallVector<TreeNodePtr, 8> VisitedNotAffectedQueue;
+#ifndef NDEBUG
+    SmallVector<TreeNodePtr, 8> VisitedUnaffected;
+#endif
   };
 
   static void InsertEdge(DomTreeT &DT, const BatchUpdatePtr BUI,
@@ -800,8 +802,10 @@ struct SemiNCAInfo {
             // vertices. Store it in UnaffectedOnCurrentLevel.
             LLVM_DEBUG(dbgs() << "\t\tMarking visited not affected "
                               << BlockNamePrinter(Succ) << "\n");
-            II.VisitedNotAffectedQueue.push_back(SuccTN);
             UnaffectedOnCurrentLevel.push_back(SuccTN);
+#ifndef NDEBUG
+            II.VisitedUnaffected.push_back(SuccTN);
+#endif
           } else {
             // The condition is satisfied (Succ is affected). Add Succ to the
             // bucket queue.
@@ -833,20 +837,13 @@ struct SemiNCAInfo {
       TN->setIDom(NCD);
     }
 
-    UpdateLevelsAfterInsertion(II);
-    if (IsPostDom) UpdateRootsAfterUpdate(DT, BUI);
-  }
-
-  static void UpdateLevelsAfterInsertion(InsertionInfo &II) {
-    LLVM_DEBUG(
-        dbgs() << "Updating levels for visited but not affected nodes\n");
+#ifndef NDEBUG
+    for (const TreeNodePtr TN : II.VisitedUnaffected)
+      assert(TN->getLevel() == TN->getIDom()->getLevel() + 1 &&
+             "TN should have been updated by an affected ancestor");
+#endif
 
-    for (const TreeNodePtr TN : II.VisitedNotAffectedQueue) {
-      LLVM_DEBUG(dbgs() << "\tlevel(" << BlockNamePrinter(TN) << ") = ("
-                        << BlockNamePrinter(TN->getIDom()) << ") "
-                        << TN->getIDom()->getLevel() << " + 1\n");
-      TN->UpdateLevel();
-    }
+    if (IsPostDom) UpdateRootsAfterUpdate(DT, BUI);
   }
 
   // Handles insertion to previously unreachable nodes.