[clang] [CIR][CUDA] Handle local, __device__, __shared__, and __constant__ variables (PR #184248)

Zaky Hermawan via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 10 18:57:58 PDT 2026


================
@@ -433,12 +435,15 @@ CIRGenModule::getOrCreateStaticVarDecl(const VarDecl &d,
   mlir::Type lty = getTypes().convertTypeForMem(ty);
   assert(!cir::MissingFeatures::addressSpace());
 
-  if (d.hasAttr<LoaderUninitializedAttr>() || d.hasAttr<CUDASharedAttr>())
+  mlir::Attribute init = nullptr;
+  if (d.hasAttr<LoaderUninitializedAttr>())
     errorNYI(d.getSourceRange(),
              "getOrCreateStaticVarDecl: LoaderUninitializedAttr");
-  assert(!cir::MissingFeatures::addressSpace());
+  else if (ty.getAddressSpace() != LangAS::opencl_local &&
+           !d.hasAttr<CUDASharedAttr>())
+    init = builder.getZeroInitAttr(convertType(ty));
 
-  mlir::Attribute init = builder.getZeroInitAttr(convertType(ty));
+  assert(!cir::MissingFeatures::addressSpace());
----------------
ZakyHermawan wrote:

createVersionedGlobal did not requrie AddressSpace as argument.
Do the assert statement still necessary ?

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


More information about the cfe-commits mailing list