llvm.org GIT mirror llvm / a1b8a23
[Dominators] Remove the NCA check 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 Jakub Kuderski 2 years ago
1 changed file(s) with 2 addition(s) and 37 deletion(s). Raw diff Collapse all Expand all
14601460 return true;
14611461 }
14621462
1463 // Checks if for every edge From -> To in the graph
1464 // NCD(From, To) == IDom(To) or To.
1465 bool verifyNCD(const DomTreeT &DT) {
1466 clear();
1467 doFullDFSWalk(DT, AlwaysDescend);
1468
1469 for (auto &BlockToInfo : NodeToInfo) {
1470 auto &Info = BlockToInfo.second;
1471
1472 const NodePtr From = NumToNode[Info.Parent];
1473 if (!From) continue;
1474
1475 const NodePtr To = BlockToInfo.first;
1476 const TreeNodePtr ToTN = DT.getNode(To);
1477 assert(ToTN);
1478
1479 const NodePtr NCD = DT.findNearestCommonDominator(From, To);
1480 const TreeNodePtr NCDTN = DT.getNode(NCD);
1481 const TreeNodePtr ToIDom = ToTN->getIDom();
1482 if (NCDTN != ToTN && NCDTN != ToIDom) {
1483 errs() << "NearestCommonDominator verification failed:\n\tNCD(From:"
1484 << BlockNamePrinter(From) << ", To:" << BlockNamePrinter(To)
1485 << ") = " << BlockNamePrinter(NCD)
1486 << ",\t (should be To or IDom[To]: " << BlockNamePrinter(ToIDom)
1487 << ")\n";
1488 errs().flush();
1489
1490 return false;
1491 }
1492 }
1493
1494 return true;
1495 }
1496
14971463 // The below routines verify the correctness of the dominator tree relative to
14981464 // the CFG it's coming from. A tree is a dominator tree iff it has two
14991465 // properties, called the parent property and the sibling property. Tarjan
16311597 bool Verify(const DomTreeT &DT) {
16321598 SemiNCAInfo SNCA(nullptr);
16331599 return SNCA.verifyRoots(DT) && SNCA.verifyReachability(DT) &&
1634 SNCA.VerifyLevels(DT) && SNCA.verifyNCD(DT) &&
1635 SNCA.verifyParentProperty(DT) && SNCA.verifySiblingProperty(DT) &&
1636 SNCA.VerifyDFSNumbers(DT);
1600 SNCA.VerifyLevels(DT) && SNCA.verifyParentProperty(DT) &&
1601 SNCA.verifySiblingProperty(DT) && SNCA.VerifyDFSNumbers(DT);
16371602 }
16381603
16391604 } // namespace DomTreeBuilder