Repository navigation
SPIR-V: stop removing freeze instructions - #1073
Merged
Merged
Conversation
Both SPIR-V back-ends lower `freeze` themselves: the Khronos translator (SPIRV-LLVM-Translator#1140) and the LLVM back-end since LLVM 19, each replacing it by its operand (or by a null constant for a frozen undef). With the SPV_KHR_poison_freeze extension, which both support as of version 23, they emit `OpFreezeKHR` instead. Stripping `freeze` beforehand made that extension impossible to use, while adding nothing over the back-ends' own fallback.
This was referenced Nov 3, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1073 +/- ##
==========================================
- Coverage 92.48% 90.95% -1.54%
==========================================
Files 31 31
Lines 7334 7320 -14
==========================================
- Hits 6783 6658 -125
- Misses 551 662 +111 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
rm_freeze!dates from 2021, when the Khronos translator couldn't handlefreeze(KhronosGroup/SPIRV-LLVM-Translator#1140). Both back-ends lower it themselves now:SPIRVRegularizeLLVM, replacesfreezewith its operand, or with a null constant if the operand isundef/poison;G_FREEZEsince LLVM 19 (Add support for the 'freeze' instruction llvm/llvm-project#82979), with the same fallback.With
SPV_KHR_poison_freezeenabled, both emit a realOpFreezeKHRas of version 23 (llvm/llvm-project#198037, KhronosGroup/SPIRV-LLVM-Translator#3751), which is what we already require. Our pass ran first and removed everyfreeze, so there was no way to use the extension.Removing the pass doesn't change the generated code. LLVM folds
freeze undeflong beforemcgen, so onlyfreezeon runtime values ever reachedrm_freeze!, and the back-ends' fallback forwards those exactly as we did. I checked this on both back-ends, with and without optimization. The new test makes surefreezegets through to SPIR-V that validates on both back-ends.The extension is still opt-in through
extensions="+SPV_KHR_poison_freeze". Using it today needsvalidate=false, optimize=false, becauseSPIRV_Tools_jll2025.4 can't parse the capability (Invalid capability operand: 5156). I'll open a separate issue for that and for enabling the extension by default.