[PATCH] D58369: [Dominators] Delete UpdateLevelsAfterInsertion used in edge insertion of depth-based search

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 18 22:15:10 PST 2019


MaskRay created this revision.
MaskRay added a reviewer: kuhar.
Herald added subscribers: llvm-commits, kristina.
Herald added a project: LLVM.

After insertion of (From, To), v is affected iff
depth(NCD)+1 < depth(v) && exists path P from To to v 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. So UpdateLevelsAfterInsertion and its bookkeeping variable VisitedNotAffectedQueue are redundant.

This property can be checked this way: add `if (TN->getLevel() != TN->getIDom()->getLevel()+1) abort();`
to the loop in UpdateLevelsAfterInsertion and see that it cannot fire.


Repository:
  rL LLVM

https://reviews.llvm.org/D58369

Files:
  include/llvm/Support/GenericDomTreeConstruction.h


Index: include/llvm/Support/GenericDomTreeConstruction.h
===================================================================
--- include/llvm/Support/GenericDomTreeConstruction.h
+++ include/llvm/Support/GenericDomTreeConstruction.h
@@ -632,7 +632,6 @@
         Bucket;
     SmallDenseSet<TreeNodePtr, 8> Visited;
     SmallVector<TreeNodePtr, 8> Affected;
-    SmallVector<TreeNodePtr, 8> VisitedNotAffectedQueue;
   };
 
   static void InsertEdge(DomTreeT &DT, const BatchUpdatePtr BUI,
@@ -800,7 +799,6 @@
             // 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);
           } else {
             // The condition is satisfied (Succ is affected). Add Succ to the
@@ -833,22 +831,9 @@
       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");
-
-    for (const TreeNodePtr TN : II.VisitedNotAffectedQueue) {
-      LLVM_DEBUG(dbgs() << "\tlevel(" << BlockNamePrinter(TN) << ") = ("
-                        << BlockNamePrinter(TN->getIDom()) << ") "
-                        << TN->getIDom()->getLevel() << " + 1\n");
-      TN->UpdateLevel();
-    }
-  }
-
   // Handles insertion to previously unreachable nodes.
   static void InsertUnreachable(DomTreeT &DT, const BatchUpdatePtr BUI,
                                 const TreeNodePtr From, const NodePtr To) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58369.187306.patch
Type: text/x-patch
Size: 1755 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190219/40c0c98d/attachment.bin>


More information about the llvm-commits mailing list