This is an archive of the discontinued LLVM Phabricator instance.

[PlaceSafepoints] Use the analysis infrastructure rather than an inner pass manager
AbandonedPublic

Authored by reames on May 13 2015, 12:11 PM.

Details

Summary

I would really appreciate careful review on the analysis update logic in the newly added function.

PlaceSafepoints was previously using an inner pass manager to run an analysis pass *after* modifying the IR to remove unreachable blocks. In an effort to get rid of the inner pass manager (and the various dominator tree recalcs it implied), I switched to using the analysis infrastructure to actually get the various analysis needed and convert the inner pass manager stuff into a small non-pass helper class.

However, I couldn't figure out how to keep the analysis results up to date over a call to removeUnreachableBlocks. That routine freely modifies the CFG in non-trivial ways with no provisions for updating any of dominator tree, or loop info. Instead, I introduced a new helper function which *only* removes blocks which aren't reachable from the function entry according to the dominator tree. This version supports analysis updating for DT, LI, and (implicitly) SE.

After making the change for PlaceSafepoints, I noticed that RewriteSafepointsForGC had a related invalidation bug. If there was an unreachable statepoint, the analysis results were out of sync with the function being processed after unreachable code was removed.

I suspect - but have not investigated in great depth - that other callers of removeUnreachableBlocks might have similar invalidation bugs. In particular, I'm extremely suspicious of CodeGen/WinEHPrepare.

Diff Detail

Event Timeline

reames updated this revision to Diff 25721.May 13 2015, 12:11 PM
reames retitled this revision from to [PlaceSafepoints] Use the analysis infrastructure rather than an inner pass manager.
reames updated this object.
reames edited the test plan for this revision. (Show Details)
reames added a subscriber: Unknown Object (MLST).
igor-laevsky added inline comments.May 14 2015, 5:26 AM
include/llvm/Transforms/Utils/Local.h
285–290

Can you please add an example on when differences between "removeBlocksNotReachableFromEntry" and "removeUnreachableBlocks" do matter?

pgavlin added inline comments.May 18 2015, 10:24 AM
include/llvm/Transforms/Utils/Local.h
285–290

+1 to this. The code looks good to me, but it would be nice to have some examples--ideally in the form of tests--of the properties of removeBlocksNotReachableFromEntry.

reames abandoned this revision.Aug 26 2015, 4:35 PM

The work that was blocking has been resolved differently and I don't have time to work through all the analysis invalidation issues.

Note to reader: Much of the context of this review didn't make it into phabricator. The blocking comments were by Danny B w.r.t. fixing the existing code to preserve analysis results.