This is an archive of the discontinued LLVM Phabricator instance.

[SPIR-V] Support memory(...) function attributes
ClosedPublic

Authored by mpaszkowski on Dec 1 2022, 11:54 AM.

Details

Summary

Adds support for memory(...) function attributes in SPIR-V function control info lowering. More about the memory effects attributes changes can be found here: https://discourse.llvm.org/t/rfc-unify-memory-effect-attributes/65579.

Diff Detail

Event Timeline

mpaszkowski created this revision.Dec 1 2022, 11:54 AM
mpaszkowski requested review of this revision.Dec 1 2022, 11:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 1 2022, 11:54 AM

This patch fixes the trivial-function-with-attributes.ll LIT test that is already present in the repository. Additionally, also the get_global_offset.ll test passes.

arsenm added inline comments.Dec 5 2022, 9:07 AM
llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
62

ReadNone still exists? I thought it was removed. Why check it?

arsenm requested changes to this revision.Dec 14 2022, 5:58 AM
arsenm added inline comments.
llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
62

Oh, readnone still exists but only applies to parameters now. There's no point in checking it on a function

This revision now requires changes to proceed.Dec 14 2022, 5:58 AM
mpaszkowski marked 2 inline comments as done.Dec 14 2022, 6:12 PM

@arsenm I have removed the checks for ReadNone and also for ReadOnly. Both are replaced with the new memory(...) attributes in functions. I will keep tests for the legacy attributes because we have compilers feeding old LLVM IR into the SPIR-V backend.

nikic added a subscriber: nikic.Dec 15 2022, 12:27 AM

@arsenm I have removed the checks for ReadNone and also for ReadOnly. Both are replaced with the new memory(...) attributes in functions. I will keep tests for the legacy attributes because we have compilers feeding old LLVM IR into the SPIR-V backend.

The old attributes are converted into the new one during IR parsing, so that probably doesn't really test anything useful?

@arsenm I have removed the checks for ReadNone and also for ReadOnly. Both are replaced with the new memory(...) attributes in functions. I will keep tests for the legacy attributes because we have compilers feeding old LLVM IR into the SPIR-V backend.

The old attributes are converted into the new one during IR parsing, so that probably doesn't really test anything useful?

Are there any plans to remove the conversion in the long term? If there are/would be then the LIT tests would give us useful information why some runtime tests are failing without the need for debugging.

The patch looks good to me. Thanks, Michal!

iliya-diyachkov accepted this revision.Dec 15 2022, 12:48 PM

@arsenm I have removed the checks for ReadNone and also for ReadOnly. Both are replaced with the new memory(...) attributes in functions. I will keep tests for the legacy attributes because we have compilers feeding old LLVM IR into the SPIR-V backend.

The old attributes are converted into the new one during IR parsing, so that probably doesn't really test anything useful?

Are there any plans to remove the conversion in the long term? If there are/would be then the LIT tests would give us useful information why some runtime tests are failing without the need for debugging.

The tests you have here would break if the parsing stops recognizing it. There's no plus to keeping the legacy check here

arsenm accepted this revision.Dec 15 2022, 5:24 PM
This revision is now accepted and ready to land.Dec 15 2022, 5:24 PM
This revision was automatically updated to reflect the committed changes.