[llvm] [SPIRV] Do not use OpTypeRuntimeArray in Kernel env. (PR #149522)
Steven Perron via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 21 07:05:29 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);
----------------
s-perron wrote:
I don't know OpenCL, but is it possible to have a zero sized array in a struct? Will making it an array of size 1 change the layout of the struct? Would it be better for the FE to change the type to an array of size 1 to avoid potential issue like that?
https://github.com/llvm/llvm-project/pull/149522
More information about the llvm-commits
mailing list