[clang] [llvm] [clang][OpenMP][SPIR-V] Fix addrspace of globals and global constants (PR #134399)

Alex Voicu via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 7 12:14:55 PDT 2025


================
@@ -5384,6 +5384,11 @@ LangAS CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D) {
     LangAS AS;
     if (OpenMPRuntime->hasAllocateAttributeForGlobalVar(D, AS))
       return AS;
+    if (LangOpts.OpenMPIsTargetDevice && getTriple().isSPIRV())
----------------
AlexVlx wrote:

This seems ok. I would suggest that we consider, in the override, returning `opencl_constant` (2) only for OCL, and otherwise returning the global var AS (1), to prevent crashing into the invalid cast problem.

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


More information about the llvm-commits mailing list