This is an archive of the discontinued LLVM Phabricator instance.

[LoopSimplifyCFG] Update MemorySSA after r353911.
ClosedPublic

Authored by asbirlea on Feb 21 2019, 11:39 AM.

Details

Summary

MemorySSA is not properly updated in LoopSimplifyCFG after recent changes. Use SplitBlock utility to resolve that and clear all updates once handleDeadExits is finished.
All updates that follow are removal of edges which are safe to handle via the removeEdge() API.
Also, deleting dead blocks is done correctly as is, i.e. delete from MemorySSA before updating the CFG and DT.

Diff Detail

Repository
rL LLVM

Event Timeline

asbirlea created this revision.Feb 21 2019, 11:39 AM
This revision was not accepted when it landed; it landed in state Needs Review.Feb 21 2019, 11:53 AM
This revision was automatically updated to reflect the committed changes.
mkazantsev added inline comments.Feb 21 2019, 10:27 PM
llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
592

I believe we should also update MSSA here. This is the execution path taken when we don't have dead blocks.

asbirlea marked 2 inline comments as done.Feb 21 2019, 11:31 PM
asbirlea added inline comments.
llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
592

Thanks for looking at this!
I believe all updates are already done at this point as far as MemorySSA is concerned.
All updates are cleared at the end of handleDeadExits, and foldTerminators only removed edges which are safe to handle with the removeEdge API (done already inside the method).
Everything needs to be correct by the time we delete blocks anyway, since deleting assumes a correct CFG+MSSA.

If you have a case showing otherwise, I'll be happy to take a look.