-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translate LLVM-IR zero-length arrays to 1-length arrays in SPIR-V #2743
Translate LLVM-IR zero-length arrays to 1-length arrays in SPIR-V #2743
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unconditionally generating non-conformant SPIR-V seems not right. The suggestion in #417 was to hide such functionality behind an option (or perhaps we should consider a SPIR-V extension?).
Why would this be non-conformant SPIR-V? |
My apologies, I completely misread your initial description. Lowering to a SPIR-V array of length 1 is of course valid SPIR-V. |
…rray of length 1 (#15663) Cherry-pick of KhronosGroup/SPIRV-LLVM-Translator#2743. The LLVM-IR type of zero-length array does not seem to have a mapping into SPIR-V type, rather it outputs an error since the obvious choice of zero-length array is not valid in SPIR-V. This, for example, prohibits us from using unbounded arrays in SYCL device kernels because they are typically represented in LLVM-IR through zero-length arrays. This PR introduces a workaround to this by lowering a zero-length array in LLVM-IR to a 1-length array in SPIR-V.
The LLVM-IR type of zero-length array does not seem to have a mapping into SPIR-V type, rather it outputs an error since the obvious choice of zero-length array is not valid in SPIR-V. This, for example, prohibits us from using unbounded arrays in SYCL device kernels because they are typically represented in LLVM-IR through zero-length arrays. This PR attempts to introduce a workaround to this by lowering a zero-length array in LLVM-IR to a 1-length array in SPIR-V.