KhronosGroup / KhronosGroup/SPIRV-Tools
spirv-opt unable to eliminate dead loads from raytracing library
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 709
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 28
Description
I have a Raytracing library that has two anyhit entrypoints (generated from slang using SLANG_TARGET_FLAG_GENERATE_WHOLE_PROGRAM). When the second entrypoint is enabled, `spirv-opt -Os` is unable to eliminate a large number of loads to the ByteAddressBuffer g_MaterialData in the shader. Downstream of this, our use of spirv-reflect `SpvReflectDescriptorBinding::byte_address_buffer_offsets` contains offsets that should have been dead code eliminated.
I am able to workaround this by not using SLANG_TARGET_FLAG_GENERATE_WHOLE_PROGRAM and instead generating SPIR-V for each entrypoint and then using `spirv-link` to link them together. However, it would be great if spirv-opt would still be able to do dead load elimination in this case. The SPIR-V library that contains the issue is attached.
[test.zip](https://github.com/user-attachments/files/16350735/test.zip)
Contributor guide
Assessment
This issue has not been assessed yet.