This is an archive of the discontinued LLVM Phabricator instance.

[PostDom] document the current handling of infinite loops and unreachables
ClosedPublic

Authored by grosser on Jul 31 2017, 1:12 PM.

Details

Summary

As we are in the process of changing the behavior of how the post-dominator tree
is computed, make sure we have some more test coverage in this area.

Current inconsistencies:

  • Newly unreachable nodes are not added as new roots, in case the PDT is updated but not rebuilt.
  • Newly unreachable loops are not added to the CFG at all (neither when building from scratch nor when updating the CFG). This is inconsistent with the fact that unreachables are added to the PDT, but unreachable loops not. On the other side, PDT relationships are not loosened at the moment in cases where new unreachable loops are built.

This commit is providing additional test coverage for
https://reviews.llvm.org/D35851

Diff Detail

Repository
rL LLVM

Event Timeline

grosser created this revision.Jul 31 2017, 1:12 PM
grosser added a comment.EditedJul 31 2017, 1:20 PM

@kuhar, @dberlin : I came up with these test cases while reviewing D35851.

I understand that these test cases will be changed in the future. However, I think these test cases are useful to understand the problem D35851 intends to resolve and the impact the chosen solution has. While we already have quite some test coverage thanks to @kuhar, we have little tests that verify
the update behavior of PDT after changes that introduce/remove virtual nodes. This is shown by the fact, that the first test case (construction of unreachables) illustrates a bug where we forget to add a new virtual exit node.

I would like to commit this change, to have some more test coverage for D35851 and especially to make the impact of D35851 more clear.

kuhar edited edge metadata.Jul 31 2017, 1:29 PM

we have little tests that verify the update behavior of PDT after changes that introduce/remove virtual nodes. This is shown by the fact, that the first test case (construction of unreachables) illustrates a bug where we forget to add a new virtual exit node.

I would like to commit this change, to have some more test coverage for D36107 and especially to make the impact of D36017 more clear.

Just to clarify a bit: the current behavior posdominator updates is just broken when it comes to root handling -- it just happens that the verifier is broken in an analogous way and blindly trusts the set of roots inside a dominator tree. If for some reason we wanted keep not including infinite loops in postdominators, then it would be still possible to fix the root-finding behavior on updates. I mean, this issue is a bit orthogonal to what D36017 tries to do.

kuhar added inline comments.Jul 31 2017, 9:52 PM
unittests/IR/DominatorTreeTest.cpp
330 ↗(On Diff #108983)

s/node/CFG node?

417 ↗(On Diff #108983)

Doesn't this test case start with two infinite loops and breaks one of them?
Maybe it would be better to show a case when there used to be an exit which got disconnected?
(Eg. additional initial edge C -> E which gets deleted in an update.)

434 ↗(On Diff #108983)

The comments in GenericDomTreeConstruction use reverse-unreachable instead of backwards unreachable. I think it would be better to stick with one name for it everywhere.

grosser updated this revision to Diff 109062.Aug 1 2017, 1:41 AM

Address kuhar's comments:

node -> CFG node

Add the second suggested test case

Use reverse unreachable
kuhar accepted this revision.Aug 1 2017, 7:25 AM

Two nitpicks, looks good otherwise.

unittests/IR/DominatorTreeTest.cpp
453 ↗(On Diff #109062)

reverse-unreachable

540 ↗(On Diff #109062)

reverse -unreachable

This revision is now accepted and ready to land.Aug 1 2017, 7:25 AM
This revision was automatically updated to reflect the committed changes.
kuhar added a comment.EditedAug 2 2017, 5:19 PM

@grosser

I've just realized that I didn't notice the TODOs in this patch when I did a code review for it.

// TODO: Can we change the PDT definition such that C remains part of the
//       CFG, at best without loosing the dominance relation D postdom B.

I don't think we reached an agreement on the second part of the TODO, as the "at best" might imply. Could you reword the second part of the comment to be less ambiguous and not to suggest that?

And a very minor nitpick: isn't it supposed to be s/loosing/losing? :)