This is an archive of the discontinued LLVM Phabricator instance.

[Dominators] Add DFS number verification
ClosedPublic

Authored by kuhar on Sep 27 2017, 1:17 PM.

Details

Summary

This patch teaches the DominatorTree verifier to check DFS In/Out numbers which are used to answer dominance queries.
DFS number verification is done in O(nlogn), so it shouldn't add much overhead on top of the O(n^3) sibling property verification.
This check should detect errors like the one spotted in PR34466 and related bug reports.

The patch also cleans up the DFS calculation a bit, as all constructed trees should have a single root now.

I see 2 new test failures when running check-all after this change:

Failing Tests (2):
    Polly :: Isl/CodeGen/OpenMP/reference-argument-from-non-affine-region.ll
    Polly :: Isl/CodeGen/OpenMP/two-parallel-loops-reference-outer-indvar.ll

which seem to happen just after Create LLVM-IR from SCoPs -- I don't have much time now, so it would be awesome if the polly folks could help me with fixing that before sending this patch :).

Diff Detail

Repository
rL LLVM

Event Timeline

kuhar created this revision.Sep 27 2017, 1:17 PM
kuhar edited the summary of this revision. (Show Details)Sep 27 2017, 1:18 PM
kuhar added inline comments.Sep 27 2017, 2:04 PM
include/llvm/Support/GenericDomTreeConstruction.h
1394 ↗(On Diff #116870)

s/sort is/sort it

grosser edited edge metadata.Sep 29 2017, 12:09 AM

Dear Kuhar,

our OpenMP backend is currently experimental (and I am traveling). Feel free to XFAIL the test cases for now. I will fix them when I get back.

Best,
Tobias

kuhar added a comment.Oct 2 2017, 7:40 AM

OK, I will XFAIL them when submitting this patch.

@dberlin, @grosser, @davide Can you please take a look at the patch?

dberlin added inline comments.Oct 2 2017, 8:40 AM
include/llvm/Support/GenericDomTreeConstruction.h
1395 ↗(On Diff #116870)

My only concern here is that this mutates the tree in a verification function.
Given its verification, i would probably push the children and dfs numbers into a new vector, and sort + check that, to avoid mutating the tree.

kuhar added inline comments.Oct 2 2017, 8:42 AM
include/llvm/Support/GenericDomTreeConstruction.h
1395 ↗(On Diff #116870)

It doesn't mutate children here -- a copy is made instead.
If it improves readability, I can change it into an construction of a new vector with explicit type instead of auto.

dberlin added inline comments.Oct 2 2017, 8:47 AM
include/llvm/Support/GenericDomTreeConstruction.h
1395 ↗(On Diff #116870)

Yeah, i missed totally missed that.

Even something like auto Children(Node->getChildren()) would be more obvious (if it works :P)

kuhar updated this revision to Diff 117388.Oct 2 2017, 10:38 AM

Make explicit copy of Node's children. Fix a typo.

kuhar marked 4 inline comments as done.Oct 2 2017, 10:38 AM
dberlin accepted this revision.Oct 2 2017, 10:51 AM
This revision is now accepted and ready to land.Oct 2 2017, 10:51 AM
This revision was automatically updated to reflect the committed changes.