This is an archive of the discontinued LLVM Phabricator instance.

[NVPTX][AsmPrinter] Respect metadata 'align' for aggregate input parameters
Needs ReviewPublic

Authored by krisb on Feb 24 2022, 8:43 AM.

Details

Reviewers
tra
jholewinski

Diff Detail

Event Timeline

krisb created this revision.Feb 24 2022, 8:43 AM
krisb requested review of this revision.Feb 24 2022, 8:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 24 2022, 8:43 AM
tra added a comment.Feb 24 2022, 12:08 PM

What is the problem the patch is intended to solve? To allow better vectorization of param-space loads/stores ?

llvm/test/CodeGen/NVPTX/align-annotation.ll
27

Does clang generate this metadata? AFAICT, it does not. https://godbolt.org/z/s9EYbdfjT
Where is this metadata expected to come from?

krisb added a comment.Mar 7 2022, 1:08 PM

What is the problem the patch is intended to solve? To allow better vectorization of param-space loads/stores ?

I guess it may help vectorization, but I do not have a particular use case.
My main motivation is to make this consistent: we already handle this metadata while emitting an aggregate as a return value, but ignore it for parameters, which is a bit unexpected if this is the same aggregate.

llvm/test/CodeGen/NVPTX/align-annotation.ll
27

Hmm, I looked at clang, and, surprisingly, it indeed doesn't generate align property, yet it generates all the other properties of nvvm.annotations metadata. We might add align to clang for the sake of completeness.
However, clang support does not matter much in this context (it could be different frontends or users could write IR manually as align is defined in NVVM IR specification). It appears that the backend already supports the metadata; so this patch does not introduce a new one, it just makes the existing a bit more consistent.

Herald added a project: Restricted Project. · View Herald TranscriptMar 7 2022, 1:08 PM
tra added inline comments.Mar 7 2022, 2:09 PM
llvm/test/CodeGen/NVPTX/align-annotation.ll
27

We might add align to clang for the sake of completeness.

Let me play a devil's advocate here.

If we lived without it till now and there's no demonstrable benefit of having it supported, I'd argue that we do not need it and we should remove it instead.

NVVM metadata is a bit of a hack, IMO. Some of the things it's used for should be done via the standard LLVM mechanisms. E.g. kernels should be using a special calling convention, types do not have the concept of alignment in LLVM, only memory accesses do. What are we supposed to do with NVVM alignment info if the user-generated code provides conflicting alignment info about the loads/stores of the data? IMO it creates more problems than it was supposed to solve.

it could be different frontends or users could write IR manually as align is defined in NVVM IR specification

NVVM IR specification is somewhat irrelevant here. LLVM != NVVM. We have already diverged quite a bit since the time NVIDIA has contributed NVPTX back-end.