This is an archive of the discontinued LLVM Phabricator instance.

[GVN] MemorySSA for GVN: use the incoming memory state in the value numbers
Needs ReviewPublic

Authored by chill on Dec 6 2021, 8:20 AM.

Diff Detail

Event Timeline

chill created this revision.Dec 6 2021, 8:20 AM
chill requested review of this revision.Dec 6 2021, 8:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 6 2021, 8:20 AM
chill planned changes to this revision.Dec 6 2021, 8:20 AM

A very broad comment for a smooth transition

  • the patches should be split into changes to GVN independent of the switch, e.g. a) factoring out components/methods where the differences between MSSA and MD occur and b) things that need to be added for the transition
  • we should keep the MD implementation and have a flag for switching between the current one and the MSSA one being added
  • once the flag flip sticks, then we'd remove the MD implementation
chill updated this revision to Diff 401905.Jan 21 2022, 2:27 AM
chill planned changes to this revision.Jan 21 2022, 2:30 AM
chill added a comment.Jan 21 2022, 2:33 AM

A very broad comment for a smooth transition

  • the patches should be split into changes to GVN independent of the switch, e.g. a) factoring out components/methods where the differences between MSSA and MD occur and b) things that need to be added for the transition
  • we should keep the MD implementation and have a flag for switching between the current one and the MSSA one being added
  • once the flag flip sticks, then we'd remove the MD implementation

Ack.

chill updated this revision to Diff 403277.Jan 26 2022, 8:09 AM
chill retitled this revision from [GVN] MemorySSA for GVN: remove MemDep form GVNPass:ValueTable to [GVN] MemorySSA for GVN: use the incoming memory state in the value numbers.
chill edited the summary of this revision. (Show Details)
chill updated this revision to Diff 407206.Feb 9 2022, 10:35 AM
chill added inline comments.Feb 16 2022, 7:21 AM
llvm/lib/Transforms/Scalar/GVN.cpp
496

I looked at this part and it looks correct:

  • if we have !AA->doesNotAccesMemory(C) we have to assign a new unique value number to account for the possibility that the call does volatile accesses or has some other form of non-determinism.
  • otherwise, if the call does not access memory, then the current memory state can't affect the return value, so we won't include it in the value number
  • otherwise, we hash the memory state too.

Nevertheless, it can be rearranged a little bit.

chill updated this revision to Diff 409331.Feb 16 2022, 10:53 AM
asbirlea added inline comments.Mar 3 2022, 2:57 PM
llvm/lib/Transforms/Scalar/GVN.cpp
2275

I'm not clear if BB always has a MemoryPhi. It's possible for a node to have PhiNodes, and no MemoryPhis.

if (!MPhi)
  return Num;

For getting the incoming value, there's an API:

MemoryAccess *MA = MPhi->getIncomingValueForBlock(Pred);
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2022, 2:57 PM
mkazantsev resigned from this revision.Mar 4 2022, 12:14 AM
chill updated this revision to Diff 417611.Mar 23 2022, 7:45 AM
chill updated this revision to Diff 428111.May 9 2022, 9:42 AM
chill updated this revision to Diff 440217.Jun 27 2022, 7:23 AM