[clang] [llvm] [CIR][CUDA] Shadow variables, internalize device side variables, lower poison attribute (PR #190087)

David Rivera via cfe-commits cfe-commits at lists.llvm.org
Tue May 5 23:21:10 PDT 2026


================
@@ -1452,13 +1472,39 @@ void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *vd,
                     cir::CUDAExternallyInitializedAttr::get(&getMLIRContext()));
       }
     } else {
-      // TODO(cir):
       // Adjust linkage of shadow variables in host compilation
-      // getCUDARuntime().internalizeDeviceSideVar(vd, linkage);
+      getCUDARuntime().internalizeDeviceSideVar(vd, linkage);
+    }
+    getCUDARuntime().handleVarRegistration(vd, gv);
+  }
+
+  // Decorate CUDA shadow variables with the cu.shadow_name attribute so we know
----------------
RiverDave wrote:

This overwrites the registration attribute you generated above (via `getCUDARuntime().handleVarRegistration(vd, gv)`). The attr generation should stay centralized in the CUDA runtime hook to match OG `CGNVCUDARuntime::handleVarRegistration`. Also, this duplicate path inverts the `extern` flag (`vd->hasDefinition()` vs OG’s `!D->hasDefinition()`).


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


More information about the cfe-commits mailing list