[PATCH] D61274: [Sema][AST] Explicit visibility for OpenCL/CUDA kernels/variables

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 29 14:21:22 PDT 2019


tra added a comment.

A kernel functions in CUDA is actually two different functions. One is the real kernel we compile for the GPU, another is a host-side stub that launches the device-side kernel.

On device side both clang and nvcc currently silently ignore `hidden` visibility and force the kernel to always be visible:
https://godbolt.org/z/xrPMGc
This is needed because the kernel must be externally visible in the device-side executable for the host-side code to execute it.
The device-side executable and its symbols are isolated from the host DSO they are encapsulated in, so whether the `hidden` attribute is ignored or not on device side is independent of the visibility the kernel symbol gets on the host side.

On the host side there's no particular reason to give kernel (or, rather, its host-side stub) a special treatment. Setting `hidden` on it should be fine, if someone needs it for whatever reason.
Most likely users who may have applied `hidden` to a kernel would do so in order to avoid exposing kernel symbols outside of a DSO and the attribute will do that job just fine.

I think the warning is not going to buy anything for CUDA. The hidden attribute effectively applies to the host side only, where it should work correctly and where it is potentially useful. I'd rather not impose restrictions that are not necessary, even if it's just a warning.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61274/new/

https://reviews.llvm.org/D61274





More information about the cfe-commits mailing list