This is an archive of the discontinued LLVM Phabricator instance.

[MSSAU] Clarify that the defining access does not matter
ClosedPublic

Authored by nikic on Aug 15 2023, 6:51 AM.

Details

Summary

New memory accesses are usually inserted by using one of the createMemoryAccessXYZ() methods followed by insertUse() or insertDef(). createMemoryAccessXYZ() accepts a defining access, however this defining access will always be overwritten by insertUse() / insertDef().

Update the documentation to clarify this, and stop passing Definition to createMemoryAccessXYZ() if it's followed by insertUse/insertDef.

Alternatively, we could also make insertUse / insertDef keep the defining access if it is specified, and only recompute it if it's missing.

Diff Detail

Event Timeline

nikic created this revision.Aug 15 2023, 6:51 AM
nikic requested review of this revision.Aug 15 2023, 6:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 15 2023, 6:51 AM
asbirlea accepted this revision.Aug 15 2023, 7:32 AM

LGTM.
Another alternative is creating a createMemoryAccess API which does not take the defining access, but likely not worth it.
I'm fairly certain we cannot keep the defining access when inserting Defs in the general case, in particular when needing to insert new Phis.

llvm/lib/Transforms/Scalar/GVN.cpp
2017–2018

Update or remove comment.

This revision is now accepted and ready to land.Aug 15 2023, 7:32 AM
khei4 added a subscriber: khei4.Aug 15 2023, 10:42 PM
This revision was landed with ongoing or failed builds.Aug 16 2023, 12:00 AM
This revision was automatically updated to reflect the committed changes.
nikic marked an inline comment as done.Aug 16 2023, 12:05 AM

Another alternative is creating a createMemoryAccess API which does not take the defining access, but likely not worth it.

We may be able to remove the Definition argument from these APIs entirely. I believe the only caller that supplies Definition now is https://github.com/llvm/llvm-project/blob/9d2f8ecac88c73242c99e7b353ac985fc57f1ed3/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp#L323-L325, so we would only need an alternative for that one.