[clang] [CUDA][HIP] Exclude external variables from constant promotion. (PR #73549)

Artem Belevich via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 5 10:29:23 PST 2023


================
@@ -104,3 +106,14 @@ void fun() {
   (void) b<double>;
   (void) var_host_only;
 }
+
+extern __global__ void external_func();
+extern void* const external_dep[] = {
----------------
Artem-B wrote:

This array is nomiannly host-only entity and should not be emitted on GPU at all, IMO. In fact, nvcc errors out if we attempt to access it on the GPU: https://godbolt.org/z/G15zn35Wd

Whether it's extern or not should not matter. I think.

@yxsamliu Sam, WDYT? I suspect there is/was a reason we may have allowed const access on both sides.

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


More information about the cfe-commits mailing list