[llvm] [SPIRV] Do not use OpTypeRuntimeArray in Kernel env. (PR #149522)

Victor Lomuller via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 21 05:17:34 PDT 2025


================
@@ -828,9 +828,11 @@ SPIRVType *SPIRVGlobalRegistry::getOpTypeArray(uint32_t NumElems,
          "Invalid array element type");
   SPIRVType *SpvTypeInt32 = getOrCreateSPIRVIntegerType(32, MIRBuilder);
   SPIRVType *ArrayType = nullptr;
-  if (NumElems != 0) {
-    Register NumElementsVReg =
-        buildConstantInt(NumElems, MIRBuilder, SpvTypeInt32, EmitIR);
+  const SPIRVSubtarget &ST =
+      cast<SPIRVSubtarget>(MIRBuilder.getMF().getSubtarget());
+  if (NumElems != 0 || !ST.isShader()) {
+    Register NumElementsVReg = buildConstantInt(
+        NumElems ? NumElems : 1, MIRBuilder, SpvTypeInt32, EmitIR);
----------------
Naghasan wrote:

> Is this the correct solution?

+1

I had an offline chat with Marcos. He'll look into changing the gep pattern that is causing issue (the SYCL compiler don't need to emit this type outside some offset computation)

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


More information about the llvm-commits mailing list