<div dir="ltr">I assume if we ever bothered to make the verification O(N) again using better algorithms, we'd go back to one level of verification?</div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 20, 2018 at 3:30 PM, Jakub Kuderski via Phabricator <span dir="ltr"><<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">kuhar created this revision.<br>
kuhar added reviewers: dberlin, brzycki, davide, grosser, dmgreen.<br>
<br>
Currently, there are 2 ways to verify a DomTree:<br>
<br>
- `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.<br>
- `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.<br>
<br>
This patch introduces DomTree verification levels, that try to close the gape between the two ways of checking trees by introducing 3 verification levels:<br>
<br>
- 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.<br>
- 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.<br>
- 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.<br>
<br>
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:<br>
<br>
- no verification: 8.3s<br>
- `DT.verify(VerificationLevel::<wbr>Fast)`: 10.1s<br>
- `DT.verify(VerificationLevel::<wbr>Basic)`: 44.8s<br>
- `DT.verify(VerificationLevel::<wbr>Basic)`: 1m 46.2s<br>
<br>
(and the previous `DT.verifyDominatorTree()` is within the noise of the Fast level)<br>
<br>
This patch makes `DT.verifyDominatorTree()` pick between the 3 verification levels depending on EXPENSIVE_CHECKS and `-verify-dom-info`.<br>
<br>
<br>
Repository:<br>
  rL LLVM<br>
<br>
<a href="https://reviews.llvm.org/D42337" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D42337</a><br>
<br>
Files:<br>
  include/llvm/IR/Dominators.h<br>
  include/llvm/Support/<wbr>GenericDomTree.h<br>
  include/llvm/Support/<wbr>GenericDomTreeConstruction.h<br>
  lib/IR/Dominators.cpp<br>
<br>
</blockquote></div><br></div>