This is an archive of the discontinued LLVM Phabricator instance.

[LoopRotate] Fix DomTree update logic for unreachable nodes. Fix PR33701.
ClosedPublic

Authored by kuhar on Jul 6 2017, 11:02 AM.

Details

Summary

LoopRotate manually updates the DoomTree by iterating over all predecessors of a basic block and computing the Nearest Common Dominator.

When a predecessor happens to be unreachable, DT.findNearestCommonDominator returns nullptr.

This patch teaches LoopRotate to handle this case and fixes PR33701.

In the future, LoopRotate should be taught to use the new incremental API for updating the DomTree.

Diff Detail

Event Timeline

kuhar created this revision.Jul 6 2017, 11:02 AM
efriedma added inline comments.
lib/Transforms/Scalar/LoopRotation.cpp
491

What if *PI isn't reachable?

kuhar updated this revision to Diff 105529.Jul 6 2017, 2:16 PM
kuhar marked an inline comment as done.
davide added inline comments.Jul 6 2017, 2:20 PM
lib/Transforms/Scalar/LoopRotation.cpp
491

How hard is to craft a test where *PI is not reachable as well?

kuhar added inline comments.Jul 6 2017, 4:24 PM
lib/Transforms/Scalar/LoopRotation.cpp
491

I haven't been able to figure that out, but the code doesn't rely on the order now. There's also an assert for a situation when all predecessors are unreachable (which I don't think is possible) that should catch situations like that.

dberlin accepted this revision.Jul 11 2017, 8:37 PM

I think this is fine for now (the test case actually tests the patch), especially if we are going to move it to use the incremental updater.
It tends to be hard to formulate certain types of testcases right now due to the preconditions of loop-rotate

This revision is now accepted and ready to land.Jul 11 2017, 8:37 PM
This revision was automatically updated to reflect the committed changes.