Currently, there are 2 ways to verify a DomTree:
- DT.verify() -- runs full tree verification and checks all the properties and gives a reason why the tree is incorrect. This is run by when EXPENSIVE_CHECKS are enabled or when -verify-dom-info flag is set.
- DT.verifyDominatorTree() -- constructs a fresh tree and compares it against the old one. This does not check any other tree properties (DFS number, levels), nor ensures that the construction algorithm is correct. Used by some passes inside assertions.
This patch introduces DomTree verification levels, that try to close the gape between the two ways of checking trees by introducing 3 verification levels:
- Full -- checks all properties, but can be slow (O(N^3)). Used when manually requested (e.g. assert(DT.verify())) or when -verify-dom-info is set.
- Basic -- checks all properties except the sibling property, and compares the current tree with a freshly constructed one instead. This should catch almost all errors, but does not guarantee that the construction algorithm is correct. Used when EXPENSIVE checks are enabled.
- Fast -- checks only basic properties (reachablility, dfs numbers, levels, roots), and compares with a fresh tree. This is meant to replace the legacy DT.verifyDominatorTree() and in my tests doesn't cause any noticeable performance impact even in the most pessimistic examples.
When used to verify dom tree wrapper pass analysis on sqlite3, the 3 new levels make opt -O3 take the following amount of time on my machine:
- no verification: 8.3s
- DT.verify(VerificationLevel::Fast): 10.1s
- DT.verify(VerificationLevel::Basic): 44.8s
- DT.verify(VerificationLevel::Full): 1m 46.2s
(and the previous DT.verifyDominatorTree() is within the noise of the Fast level)
This patch makes DT.verifyDominatorTree() pick between the 3 verification levels depending on EXPENSIVE_CHECKS and -verify-dom-info.
Is the Full level the same as what verify did before this patch? I'm curious how the default level was chosen.