This is an archive of the discontinued LLVM Phabricator instance.

[CUDA/SPIR-V] Force passing aggregate type byval
ClosedPublic

Authored by shangwuyao on Jul 22 2022, 12:24 PM.

Details

Summary

This patch forces copying aggregate type in kernel arguments by value when
compiling CUDA targeting SPIR-V. The original behavior is not passing by value
when there is any of destructor, copy constructor and move constructor defined
by user. This patch makes the behavior of SPIR-V generated from CUDA follow
the CUDA spec
(https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#global-function-argument-processing),
and matches the NVPTX
implementation (
https://github.com/llvm/llvm-project/blob/41958f76d8a2c47484fa176cba1de565cfe84de7/clang/lib/CodeGen/TargetInfo.cpp#L7241).

Diff Detail

Event Timeline

shangwuyao created this revision.Jul 22 2022, 12:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2022, 12:24 PM
shangwuyao requested review of this revision.Jul 22 2022, 12:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2022, 12:24 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
tra accepted this revision.Jul 22 2022, 1:14 PM

LGTM with a couple of nits.

clang/lib/CodeGen/TargetInfo.cpp
10453

I would add a comment that this is a CUDA-specific behavior with the pointer to the relevant CUDA doc explaining what's going on.

10453
This revision is now accepted and ready to land.Jul 22 2022, 1:14 PM
This revision was landed with ongoing or failed builds.Jul 22 2022, 1:30 PM
This revision was automatically updated to reflect the committed changes.

Accidentally submitted early...

tra added a comment.Jul 22 2022, 1:38 PM

Accidentally submitted early...

The landed revision seems to have my comments addressed. Was there something missing?

Accidentally submitted early...

The landed revision seems to have my comments addressed. Was there something missing?

No, just want to wait a bit longer to see if someone else has comments.

tra added a comment.Jul 22 2022, 1:42 PM

It's OK. If something comes up you can address it in a follow-up patch.