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

Nick Sarnie via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 7 11:29:30 PDT 2025


================
@@ -5402,6 +5407,10 @@ LangAS CodeGenModule::GetGlobalConstantAddressSpace() const {
     // UniformConstant storage class is not viable as pointers to it may not be
     // casted to Generic pointers which are used to model HIP's "flat" pointers.
     return LangAS::cuda_device;
+  if (LangOpts.OpenMPIsTargetDevice && getTriple().isSPIRV())
+    // OpenMP SPIR-V global constants should map to UniformConstant, different
+    // from the HIPSPV case above.
+    return LangAS::opencl_constant;
----------------
sarnex wrote:

Yeah I hit something similar when trying to use `addrspace(4)` for generic. For constants it seems to be working okay for now, hopefully it's okay with you if I try this for now and then extend the solution if a problem comes up.

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


More information about the llvm-commits mailing list