This is an archive of the discontinued LLVM Phabricator instance.

[IR] Add support for memory attribute
ClosedPublic

Authored by nikic on Oct 10 2022, 8:29 AM.

Details

Summary

This implements IR and bitcode support for the memory attribute, as proposed in https://discourse.llvm.org/t/rfc-unify-memory-effect-attributes/65579.

The new attribute is not used for anything yet (and as such, the old memory attributes are unaffected).

Diff Detail

Event Timeline

nikic created this revision.Oct 10 2022, 8:29 AM
nikic requested review of this revision.Oct 10 2022, 8:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 10 2022, 8:29 AM
nikic updated this revision to Diff 467102.Oct 12 2022, 5:27 AM

Print as memory(none) instead of memory() to make the meaning more obvious.

Am I blind or does this not actually contain the bitcode parts yet? Generally looks fine to me at a glance, I expect you're going to rebase on top of the MemoryEffects rename.

nikic updated this revision to Diff 468140.Oct 17 2022, 2:36 AM

Upload the correct patch... I accidentally replaced this with the next patch in the series.

nikic added a comment.Oct 17 2022, 2:37 AM

Am I blind or does this not actually contain the bitcode parts yet? Generally looks fine to me at a glance, I expect you're going to rebase on top of the MemoryEffects rename.

Ooops, I uploaded the wrong patch during the last update. Any yes, this will need to be adjusted for the MemoryEffects rename, and also for some of the LangRef changes (memory() should be rejected and the other location kind dropped).

nikic updated this revision to Diff 468831.Oct 19 2022, 2:52 AM

Update according to LangRef changes, rebase over MemoryEffects rename.

I think this one is ready for review now.

Looks good overall, the other uses confused me though.

llvm/lib/IR/Attributes.cpp
512

Here and in the examples, did we go back on the other front?

nikic added inline comments.Oct 19 2022, 11:18 AM
llvm/lib/IR/Attributes.cpp
512

other is not available in textual IR, but it is part of the in-memory representation -- we do need *some* way to internally represent everything that does not have a dedicated location kind.

jdoerfert accepted this revision.Oct 19 2022, 1:51 PM

LG from my end. one nit and one suggestions. I doubt there is anything controversial so this should be OK to land.

llvm/lib/IR/Attributes.cpp
512

Fair, I got confused by the negative test case below.
That said, can we rename it? Default? Something other than other.
For one, "other" sounds odd, second, it's somewhat tainted now.
Anyway, that should not stop this patch, just a thought.

llvm/test/Assembler/memory-attribute-errors.ll
2

I didn't know this one, really cool!

llvm/test/Assembler/memory-attribute.ll
64

Add a test that reorders them too. I hope we emit a stable order.

This revision is now accepted and ready to land.Oct 19 2022, 1:51 PM
nhaehnle accepted this revision.Oct 20 2022, 3:40 AM
This revision was landed with ongoing or failed builds.Oct 21 2022, 3:11 AM
This revision was automatically updated to reflect the committed changes.
nikic marked 2 inline comments as done.