This is an archive of the discontinued LLVM Phabricator instance.

[NewGVN] Fix verification of MemoryPhis in verifyMemoryCongruency()
ClosedPublic

Authored by davide on May 10 2017, 8:17 AM.

Details

Summary

verifyMemoryCongruency() filters out trivially dead MemoryDef, as we find them immediately dead, before moving from TOP to a new congruence class.
If you consider the testcase attached, I think we may have the same problem for PHI, and I think we may want to skip MemoryPhis if all the operands are dead.

This is the MemorySSA dump

0 = MemoryDef(liveOnEntry)
1 = MemoryDef(liveOnEntry)
2 = MemoryDef(1)
3 = MemoryPhi({entry,1},{body,2})

Looking at the operands of 3, they're both uses of trivially dead defs.

Skipping trivially dead instruction   call void @llvm.lifetime.start.p0i8(i64 4, i8* undef)
Marking   call void @llvm.lifetime.start.p0i8(i64 4, i8* undef) for deletion
Skipping trivially dead instruction   call void @llvm.lifetime.start.p0i8(i64 4, i8* undef)
Marking   call void @llvm.lifetime.start.p0i8(i64 4, i8* undef) for deletion

so we never move them out of TOP, and the phi is dead as well. Otherwise, we think this is reachable, and we hit an assertion.

Diff Detail

Repository
rL LLVM

Event Timeline

davide created this revision.May 10 2017, 8:17 AM
dberlin edited edge metadata.May 14 2017, 8:32 PM

It's definitely going to be the case that verifyMemoryCongruency is going to have false positives. It can't ever be 100% correct without it being an alternative value numbering method that is provably correct and as complete as our current one :)

Thus, it's limited to doing checks on "likely to be wrong" cases.

So i'm fine with improving it, but we're going to have to disable large parts of it at some point as our value numbering becomes more powerful.
(because we will always be better at finding congruences that it can't be convinced are correct :P)

dberlin accepted this revision.May 14 2017, 8:32 PM
This revision is now accepted and ready to land.May 14 2017, 8:32 PM
This revision was automatically updated to reflect the committed changes.