[llvm] [SPIRV] Error for zero-length arrays if not a shader (PR #169732)

Marcos Maronas via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 27 02:30:38 PST 2025


================
@@ -883,10 +883,15 @@ SPIRVType *SPIRVGlobalRegistry::getOpTypeArray(uint32_t NumElems,
           .addUse(NumElementsVReg);
     });
   } else {
-    assert(ST.isShader() && "Runtime arrays are not allowed in non-shader "
-                            "SPIR-V modules.");
-    if (!ST.isShader())
-      return nullptr;
+    if (!ST.isShader()) {
+      Function &Fn = MIRBuilder.getMF().getFunction();
+      Fn.getContext().diagnose(DiagnosticInfoUnsupported(
+          Fn,
+          "Runtime arrays are not allowed in non-shader "
+          "SPIR-V modules",
+          MIRBuilder.getDebugLoc()));
+      return ElemType;
----------------
maarquitos14 wrote:

I'm not sure this is what we want to do. The caller of this function is expecting an `OpTypeArray`, but we will be returning the `ElemType` in this case. Can you please explain why that is okay? And why is that better than returning `nullptr`, which signals that something went wrong?

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


More information about the llvm-commits mailing list