]> granicus.if.org Git - llvm/commitdiff
[Dominators] Remove the NCA check
authorJakub Kuderski <kubakuderski@gmail.com>
Sat, 14 Oct 2017 03:00:56 +0000 (03:00 +0000)
committerJakub Kuderski <kubakuderski@gmail.com>
Sat, 14 Oct 2017 03:00:56 +0000 (03:00 +0000)
Summary:
This patch removes the `verifyNCD` check.

The reason for this is that the other checks are sufficient to prove or disprove correctness of any DominatorTree, and that `verifyNCD` doesn't provide (in my option) better error messages then the other ones.
Additionally, this should give a (small) improvement to the total verification time, as the check is O(n), and checking the sibling property takes O(n^3).

Reviewers: dberlin, grosser, davide, brzycki

Reviewed By: brzycki

Subscribers: llvm-commits

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

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

include/llvm/Support/GenericDomTreeConstruction.h

index 460110eb70b701008a0269b7e71c9b08d3416514..8f801662d0fb62d6d2513f7186af67c7b016db2e 100644 (file)
@@ -1461,40 +1461,6 @@ struct SemiNCAInfo {
     return true;
   }
 
-  // Checks if for every edge From -> To in the graph
-  //     NCD(From, To) == IDom(To) or To.
-  bool verifyNCD(const DomTreeT &DT) {
-    clear();
-    doFullDFSWalk(DT, AlwaysDescend);
-
-    for (auto &BlockToInfo : NodeToInfo) {
-      auto &Info = BlockToInfo.second;
-
-      const NodePtr From = NumToNode[Info.Parent];
-      if (!From) continue;
-
-      const NodePtr To = BlockToInfo.first;
-      const TreeNodePtr ToTN = DT.getNode(To);
-      assert(ToTN);
-
-      const NodePtr NCD = DT.findNearestCommonDominator(From, To);
-      const TreeNodePtr NCDTN = DT.getNode(NCD);
-      const TreeNodePtr ToIDom = ToTN->getIDom();
-      if (NCDTN != ToTN && NCDTN != ToIDom) {
-        errs() << "NearestCommonDominator verification failed:\n\tNCD(From:"
-               << BlockNamePrinter(From) << ", To:" << BlockNamePrinter(To)
-               << ") = " << BlockNamePrinter(NCD)
-               << ",\t (should be To or IDom[To]: " << BlockNamePrinter(ToIDom)
-               << ")\n";
-        errs().flush();
-
-        return false;
-      }
-    }
-
-    return true;
-  }
-
   // The below routines verify the correctness of the dominator tree relative to
   // the CFG it's coming from.  A tree is a dominator tree iff it has two
   // properties, called the parent property and the sibling property.  Tarjan
@@ -1632,9 +1598,8 @@ template <class DomTreeT>
 bool Verify(const DomTreeT &DT) {
   SemiNCAInfo<DomTreeT> SNCA(nullptr);
   return SNCA.verifyRoots(DT) && SNCA.verifyReachability(DT) &&
-         SNCA.VerifyLevels(DT) && SNCA.verifyNCD(DT) &&
-         SNCA.verifyParentProperty(DT) && SNCA.verifySiblingProperty(DT) &&
-         SNCA.VerifyDFSNumbers(DT);
+         SNCA.VerifyLevels(DT) && SNCA.verifyParentProperty(DT) &&
+         SNCA.verifySiblingProperty(DT) && SNCA.VerifyDFSNumbers(DT);
 }
 
 }  // namespace DomTreeBuilder