[clang] [CIR] Fix address space of string literals (PR #226996)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 28 07:54:18 PDT 2026


================
@@ -2356,12 +2358,27 @@ CIRGenModule::getAddrOfConstantStringFromLiteral(const StringLiteral *s,
   cir::GlobalOp gv = getGlobalForStringLiteral(s, name);
   auto arrayTy = mlir::dyn_cast<cir::ArrayType>(gv.getSymType());
   assert(arrayTy && "String literal must be array");
-  assert(!cir::MissingFeatures::addressSpace());
-  cir::PointerType ptrTy = getBuilder().getPointerTo(arrayTy.getElementType());
+  cir::PointerType ptrTy = getBuilder().getPointerTo(
+      arrayTy.getElementType(),
+      getTypes().getPointerAddressSpace(s->getType()));
 
   return builder.getGlobalViewAttr(ptrTy, gv);
 }
 
+LangAS CIRGenModule::getGlobalConstantAddressSpace() const {
+  if (langOpts.OpenCL)
+    return LangAS::opencl_constant;
+  if (langOpts.SYCLIsDevice) {
+    errorNYI("SYCL global constant address space");
----------------
Fznamznon wrote:

I wonder if that NYI is a big deal?
Otherwise we could move that function to CodeGenUtils since it does the same as OGCG version and has nothing to do with CIR aside from this NYI.

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


More information about the cfe-commits mailing list