KhronosGroup / KhronosGroup/SPIRV-LLVM-Translator
Translation of __spirv_BuiltIn{Name} should override storage class to Input
- Dominant language
- LLVM
- Stars
- 625
- Forks
- 279
- Avg merge
- 3d 5h
- Merged PRs (30d)
- 34
Description
Per the OpenCL SPIR-V environment spec: https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_Env.html#_built_in_variables
> All built-in variables must be in the Input storage class.
Currently, in the SPIRV-LLVM-Translator, built-in handling is done after the storage class is already determined: https://github.com/KhronosGroup/SPIRV-LLVM-Translator/blob/d5573a03fbcc41c52f9820f6f83afccdd8c34d66/lib/SPIRV/SPIRVWriter.cpp#L1483. As a result, the storage class ends up being whatever was declared in the LLVM IR... but there's no SPIR mapping for the Input storage class, so it's impossible to generate correct SPIR-V using this approach.
Contributor guide
Research direction
Read the OpenCL SPIR-V environment specification and inspect lib/SPIRV/SPIRVWriter.cpp around line 1483, where built-in handling occurs after storage-class determination. Confirm that translating __spirv_BuiltIn{Name} produces SPIR-V built-in variables with the Input storage class rather than inheriting the LLVM IR declaration's storage class.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100