This is an archive of the discontinued LLVM Phabricator instance.

[MemorySSA] Fix removing dead accesses from MemoryPhis.
AbandonedPublic

Authored by fhahn on Sep 20 2020, 2:40 PM.

Details

Summary

The current logic to remove all uses of MemoryAccess defined in dead
blocks from MemoryPhis outside the set of dead blocks. MemoryPhis using
a definition from a dead block do not necessarily have to be in a direct
successor of a dead block, for example if the successor does not contain
any memory accesses.

To catch those additional MemoryPhis that need updating we need to check
all uses of all memory defs in the dead blocks and remove them from any
MemoryPhi outside the set of dead blocks.

Note that we sill need the existing code where we check the successors
for memory phis to catch the case where a MemoryPhi has an incoming
value from a dead block but is not defined in any dead block.

This can happen during unswitching, where a region between the memory
def and a memory phi becomes unreachable.

I *think* there's still a case we might miss in the above case: when the
memory phi is not a direct successor of a dead block. Not sure if this
can happen in practice.

Fixes PR47557.

Note that I did not manage to reduce the test cases so far that it only
requires a single pass to crash.

Diff Detail

Event Timeline

fhahn created this revision.Sep 20 2020, 2:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 20 2020, 2:40 PM
fhahn requested review of this revision.Sep 20 2020, 2:40 PM
fhahn abandoned this revision.Sep 21 2020, 1:56 AM

Turns out that things actually go slightly wrong earlier during LSR. LSR did not pass MSSU to SplitCriticalEdge, which caused the MemoryPhi to have slightly wrong incoming blocks. I pushed a fix for that, as it is straight-forward to fix (57ae9bb9323548b2ad4ba8274c3910bf9c764983). With that, this patch is no longer needed for the test case.