[llvm] [HLSL][SPIRV] Codegen unbound array as OpTypeRuntimeArray (PR #185551)
Steven Perron via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 11 06:50:43 PDT 2026
=?utf-8?q?João?= Saffran <joaosaffranllvm at gmail.com>,Joao Saffran
<joaosaffranllvm at gmail.com>,
=?utf-8?q?João?= Saffran <joaosaffranllvm at gmail.com>,Joao Saffran
<joaosaffranllvm at gmail.com>,
=?utf-8?q?João?= Saffran <joaosaffranllvm at gmail.com>,Joao Saffran
<joaosaffranllvm at gmail.com>,Joao Saffran <joaosaffranllvm at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/185551 at github.com>
s-perron wrote:
That is what I expected. We can do a targeted change in the spir-v backend:
https://github.com/llvm/llvm-project/blob/6f23ba2555f6d9ab271fc6fc67a7bc9c946cb7ec/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp#L5869
If ArraySize is UINT_MAX, then we can change the array size to 0. I think that solves your problem.
Here are somethings to keep in mind:
1. SPIR-V allows arrays with size UINT_MAX. In the spir-v spec there is nothing stopping it. We should be able to represent it.
2. A runtime array is not allowed in all contexts, so converting to a runtime array may lead to invalid code.
If the definition of the intrinsic says `-1` is used for arrays with unknown size, then I think my suggestion is the best solution. However, we could also consider using 0 to represent unknown size in the intrinsize instead of `-1`, but I don't think that will have a practical difference. Who wants that many descriptors?
https://github.com/llvm/llvm-project/pull/185551
More information about the llvm-commits
mailing list