Skip to content

Commit 369e85a

Browse files
committed
[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 llvm-svn: 315790
1 parent 1963f51 commit 369e85a

File tree

1 file changed

+2
-37
lines changed

1 file changed

+2
-37
lines changed

llvm/include/llvm/Support/GenericDomTreeConstruction.h

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,40 +1461,6 @@ struct SemiNCAInfo {
14611461
return true;
14621462
}
14631463

1464-
// Checks if for every edge From -> To in the graph
1465-
// NCD(From, To) == IDom(To) or To.
1466-
bool verifyNCD(const DomTreeT &DT) {
1467-
clear();
1468-
doFullDFSWalk(DT, AlwaysDescend);
1469-
1470-
for (auto &BlockToInfo : NodeToInfo) {
1471-
auto &Info = BlockToInfo.second;
1472-
1473-
const NodePtr From = NumToNode[Info.Parent];
1474-
if (!From) continue;
1475-
1476-
const NodePtr To = BlockToInfo.first;
1477-
const TreeNodePtr ToTN = DT.getNode(To);
1478-
assert(ToTN);
1479-
1480-
const NodePtr NCD = DT.findNearestCommonDominator(From, To);
1481-
const TreeNodePtr NCDTN = DT.getNode(NCD);
1482-
const TreeNodePtr ToIDom = ToTN->getIDom();
1483-
if (NCDTN != ToTN && NCDTN != ToIDom) {
1484-
errs() << "NearestCommonDominator verification failed:\n\tNCD(From:"
1485-
<< BlockNamePrinter(From) << ", To:" << BlockNamePrinter(To)
1486-
<< ") = " << BlockNamePrinter(NCD)
1487-
<< ",\t (should be To or IDom[To]: " << BlockNamePrinter(ToIDom)
1488-
<< ")\n";
1489-
errs().flush();
1490-
1491-
return false;
1492-
}
1493-
}
1494-
1495-
return true;
1496-
}
1497-
14981464
// The below routines verify the correctness of the dominator tree relative to
14991465
// the CFG it's coming from. A tree is a dominator tree iff it has two
15001466
// properties, called the parent property and the sibling property. Tarjan
@@ -1632,9 +1598,8 @@ template <class DomTreeT>
16321598
bool Verify(const DomTreeT &DT) {
16331599
SemiNCAInfo<DomTreeT> SNCA(nullptr);
16341600
return SNCA.verifyRoots(DT) && SNCA.verifyReachability(DT) &&
1635-
SNCA.VerifyLevels(DT) && SNCA.verifyNCD(DT) &&
1636-
SNCA.verifyParentProperty(DT) && SNCA.verifySiblingProperty(DT) &&
1637-
SNCA.VerifyDFSNumbers(DT);
1601+
SNCA.VerifyLevels(DT) && SNCA.verifyParentProperty(DT) &&
1602+
SNCA.verifySiblingProperty(DT) && SNCA.VerifyDFSNumbers(DT);
16381603
}
16391604

16401605
} // namespace DomTreeBuilder

0 commit comments

Comments
 (0)