[clang] [HIP][CUDA] Apply protected visibility to kernels and globals (PR #187784)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 24 06:18:56 PDT 2026


================
@@ -1899,6 +1899,27 @@ void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
     return;
   }
 
+  // CUDA/HIP device kernels and global variables must be visible to the host
+  // so they can be registered / initialized. We require protected visibility
+  // unless the user explicitly requested hidden via an attribute.
+  if (Context.getLangOpts().CUDAIsDevice &&
----------------
Fznamznon wrote:

SYCL 2020 only allows const/constexpr constant-initialized global variables, so I don't think this is currently important for SYCL therefore I don't want to block this with SYCL. We can revisit this later if device_global extension ever makes it here which I assume won't be happening soon.

https://github.com/llvm/llvm-project/pull/187784


More information about the cfe-commits mailing list