[clang] [CIR][HIP][SPIR-V] Emit constant globals in addrspace(1) (PR #230813)

Arseniy Obolenskiy via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 12 01:48:59 PDT 2026


================
@@ -2327,6 +2328,18 @@ CIRGenModule::getAddrOfConstantStringFromLiteral(const StringLiteral *s,
   return builder.getGlobalViewAttr(ptrTy, gv);
 }
 
+mlir::ptr::MemorySpaceAttrInterface
+CIRGenModule::getGlobalCIRAddressSpace(LangAS as) {
+  // The cir::LangAddressSpace fold loses the SPIRDefIsGenMap split between
+  // cuda_constant and opencl_constant, so use the target map like classic.
+  if (langOpts.CUDAIsDevice && getTriple().isSPIRV() &&
+      (as == LangAS::cuda_device || as == LangAS::cuda_constant ||
+       as == LangAS::cuda_shared))
+    return cir::TargetAddressSpaceAttr::get(
+        &getMLIRContext(), astContext.getTargetAddressSpace(as));
+  return cir::toCIRAddressSpaceAttr(getMLIRContext(), as);
----------------
aobolensk wrote:

Extracted this part here: https://github.com/llvm/llvm-project/pull/231098

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


More information about the cfe-commits mailing list