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

Scott Linder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 29 12:18:55 PDT 2019


scott.linder created this revision.
scott.linder added reviewers: Anastasia, tra, yaxunl, rjmccall.
Herald added subscribers: cfe-commits, tpr.
Herald added a project: clang.

For AMDGPU the visibility of these symbols (OpenCL kernels, CUDA `__global__` functions, and CUDA `__device__` variables) must not be hidden, as we rely on them being available in the dynamic symbol table in the final DSO.

This patch implements this by considering language attributes as a source of explicit visibility, but rather than attributing any one visibility to them they are simply coerced to be a non-hidden visibility. This allows for the optimization of using protected visibility when these symbols are known to be `dso_local`.

This patch also adds diagnostics for explicitly setting a hidden visibility on these symbols.

I imagine there are a number of issues with the patch in its current state, but I wanted to get something implemented before reaching out to OpenCL/CUDA maintainers to see if this is a reasonable change. @Anastasia and @tra I wasn't certain if you would be good candidates to discuss this change, so please let me know if I need to keep looking.


Repository:
  rC Clang

https://reviews.llvm.org/D61274

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Visibility.h
  lib/AST/Decl.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/SemaCUDA/visibility-diagnostics.cu
  test/SemaOpenCL/visibility-diagnostics.cl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61274.197157.patch
Type: text/x-patch
Size: 6103 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190429/ce8d2246/attachment.bin>


More information about the cfe-commits mailing list