Skip to content

SPIR-V: stop removing freeze instructions - #1073

Merged
maleadt merged 1 commit into
mainfrom
tb/spirv_freeze
Nov 3, 2026
Merged

maleadt merged 1 commit into
mainfrom
tb/spirv_freeze

Conversation

@maleadt

@maleadt maleadt commented Nov 3, 2026

Copy link
Copy Markdown
Member

rm_freeze! dates from 2021, when the Khronos translator couldn't handle freeze (KhronosGroup/SPIRV-LLVM-Translator#1140). Both back-ends lower it themselves now:

With SPV_KHR_poison_freeze enabled, both emit a real OpFreezeKHR as of version 23 (llvm/llvm-project#198037, KhronosGroup/SPIRV-LLVM-Translator#3751), which is what we already require. Our pass ran first and removed every freeze, so there was no way to use the extension.

Removing the pass doesn't change the generated code. LLVM folds freeze undef long before mcgen, so only freeze on runtime values ever reached rm_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 sure freeze gets 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 needs validate=false, optimize=false, because SPIRV_Tools_jll 2025.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.

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.
@codecov

codecov Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.95%. Comparing base (b90c3cb) to head (5f38a72).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@maleadt
maleadt merged commit f559b81 into main Nov 3, 2026
36 checks passed
@maleadt
maleadt deleted the tb/spirv_freeze branch November 3, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant