This is an archive of the discontinued LLVM Phabricator instance.

[MemorySSA] Cleanup trivial phis.
ClosedPublic

Authored by asbirlea on Jun 14 2019, 12:10 PM.

Details

Summary

This is unfortunately needed for correctness, if we are to extend the tolerance of the update API to the way simple loop unswitch is doing cloning.

In simple loop unswitch (as opposed to loop unswitch), not all blocks are cloned. This can create unreachable cloned blocks (no predecessor), which are later cleaned up.

In MemorySSA, the APIs for supporting these kind of updates (clone + update exit blocks), make certain assumption on the integrity of the CFG. When cloning, if something was not cloned, it's values in MemorySSA default to LiveOnEntry. When updating exit blocks, it is safe to assume that we can first insert phis in the blocks merging two clones, then add additional phis in the IDF of the blocks that received phis. This no longer holds true if one of the clones being merged comes from an unreachable block. We'd conservatively need to add all phis before filling in their incoming definitions. In practice this restriction can be relaxed if we clean up trivial phis after the first round of insertion.

Diff Detail

Repository
rL LLVM

Event Timeline

asbirlea created this revision.Jun 14 2019, 12:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 14 2019, 12:10 PM
Herald added subscribers: Prazek, jlebar. · View Herald Transcript
This revision is now accepted and ready to land.Jun 17 2019, 7:13 PM
This revision was automatically updated to reflect the committed changes.