[PR #674] [MERGED] rdna2spirv: put back the instructions llvm-mc's junk swallowed after a tuple into vcc (SHADER-VCC-TUPLE-RESYNC) #713

Closed
opened 2026-11-26 20:18:48 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/674
Author: @DadaCap
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: vcc-tuple-resync


📝 Commits (8)

  • f8d0c75 Merge remote-tracking branch 'origin/main' into HEAD
  • f605f8a rdna2spirv: put back the instructions llvm-mc's junk swallowed after a tuple into vcc
  • 6886740 test_vcc_tuple_fallback: cover where a resync starts and stops
  • 091cd96 rdna2spirv: restrict restore_vcc_tuples to reachable offsets and protect branch targets
  • 30450e0 Merge #596's head (091cd9680); restore_vcc_tuples decodes for the shader's wave size
  • bc245e5 Merge remote-tracking branch 'origin/main' into vcc-tuple-resync
  • 686f914 Merge main into vcc-tuple-resync: restore_vcc_tuples next to widen_wave64_masks
  • a6b851d Merge origin/main into vcc-tuple-resync: one recovery function for the forms llvm-mc skips

📊 Changes

6 files changed (+378 additions, -79 deletions)

View changed files

📝 docs/design.md (+1 -1)
📝 docs/shader_library.md (+7 -2)
📝 tests/semantic/test_library_compute_forms.py (+4 -3)
📝 tests/semantic/test_vcc_tuple_fallback.py (+223 -3)
📝 tests/test_rdna2spirv_decode.py (+1 -1)
📝 tools/rdna2spirv.py (+142 -69)

📄 Description

Claimed in the coordination issue as: SHADER-VCC-TUPLE-RESYNC (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7129901990)

Depends on: #596 (its two commits come first here; this pull request is the last commit)

What and why

llvm-mc rejects a scalar tuple that runs into vcc and prints the tuple's second word as junk. #596 decodes the tuple from the blob and drops the junk. But the junk is often longer than that word (an 8-byte exp, for example), so it also covers the instruction after the tuple: an s_mov_b32, an s_waitcnt, a v_fma_f32. Nothing printed that instruction at its own place, so it stayed missing and the program was refused with "fall-through into undecodable words".

restore_vcc_tuples now decodes the words after a restored tuple from the blob, the same way, until the stream is back at an instruction llvm-mc printed there. A word llvm-mc itself rejected, with no junk printed over it, is not taken for swallowed code and stays refused.

Tested

Whole pipeline library (1.0.2.1, own copy), all 2,684 compute programs, llvm-mc 21.1.8, --wave64-emulate, main + #596 without and with this commit:

#596 + this
translated 1,816 2,567
pass spirv-val 1,816 2,567
"fall-through into undecodable words" 833 3

0 programs lost, and the 1,816 modules are byte-identical. What is left: 80 s_load_dword* with a vcc base or destination (#647 has the bases), 18 s_flbit_i32_b64 and 6 s_bitreplicate_b64_b32 (#593), 9 that cannot be re-anchored, 3 fall-throughs, 1 s_sethalt. The 26,503 main-corpus listings have no undecodable words with this disassembler, so this path does not run on them.

  • tests/semantic/test_vcc_tuple_fallback.py: 7 tests pass; the new case is red without the fix, and a second one checks that a rejected word after a tuple is still refused.
  • Whole translator suite: 466 files, 6,115 tests, all pass but test_image_cube_store_glc, which fails here with FileNotFoundError starting an external program, on main too.
  • The tests/test_docs_*.py set, test_text_write_line_endings.py, compileall, check_no_game_data.py: clean.

The new modules are checked by spirv-val only; none was compared with hardware.

GPUs tested: n/a

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/674 **Author:** [@DadaCap](https://github.com/DadaCap) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `vcc-tuple-resync` --- ### 📝 Commits (8) - [`f8d0c75`](https://github.com/ubiquitarianism/leonida/commit/f8d0c75ad4e3add424d547e666fbf4c7694c2a22) Merge remote-tracking branch 'origin/main' into HEAD - [`f605f8a`](https://github.com/ubiquitarianism/leonida/commit/f605f8aee471020da29f9bf63df5036cd04ccd26) rdna2spirv: put back the instructions llvm-mc's junk swallowed after a tuple into vcc - [`6886740`](https://github.com/ubiquitarianism/leonida/commit/688674095cba178f3e0ae9d66710f364af4f5d50) test_vcc_tuple_fallback: cover where a resync starts and stops - [`091cd96`](https://github.com/ubiquitarianism/leonida/commit/091cd9680bc90a7bbad8ec0333be3878e198b2e3) rdna2spirv: restrict restore_vcc_tuples to reachable offsets and protect branch targets - [`30450e0`](https://github.com/ubiquitarianism/leonida/commit/30450e0e96e1df700bbfa9505433c9b9940e8694) Merge #596's head (091cd9680); restore_vcc_tuples decodes for the shader's wave size - [`bc245e5`](https://github.com/ubiquitarianism/leonida/commit/bc245e5046124941bbdc7bb5c3bd7c739da4e03e) Merge remote-tracking branch 'origin/main' into vcc-tuple-resync - [`686f914`](https://github.com/ubiquitarianism/leonida/commit/686f914b76458e25a8c0a280a209d101a691a949) Merge main into vcc-tuple-resync: restore_vcc_tuples next to widen_wave64_masks - [`a6b851d`](https://github.com/ubiquitarianism/leonida/commit/a6b851dff5d893017db727011b2731f1c76bac3a) Merge origin/main into vcc-tuple-resync: one recovery function for the forms llvm-mc skips ### 📊 Changes **6 files changed** (+378 additions, -79 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) 📝 `docs/shader_library.md` (+7 -2) 📝 `tests/semantic/test_library_compute_forms.py` (+4 -3) 📝 `tests/semantic/test_vcc_tuple_fallback.py` (+223 -3) 📝 `tests/test_rdna2spirv_decode.py` (+1 -1) 📝 `tools/rdna2spirv.py` (+142 -69) </details> ### 📄 Description Claimed in the coordination issue as: SHADER-VCC-TUPLE-RESYNC (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7129901990) Depends on: #596 (its two commits come first here; this pull request is the last commit) ### What and why llvm-mc rejects a scalar tuple that runs into `vcc` and prints the tuple's second word as junk. #596 decodes the tuple from the blob and drops the junk. But the junk is often longer than that word (an 8-byte `exp`, for example), so it also covers the instruction *after* the tuple: an `s_mov_b32`, an `s_waitcnt`, a `v_fma_f32`. Nothing printed that instruction at its own place, so it stayed missing and the program was refused with "fall-through into undecodable words". `restore_vcc_tuples` now decodes the words after a restored tuple from the blob, the same way, until the stream is back at an instruction llvm-mc printed there. A word llvm-mc itself rejected, with no junk printed over it, is not taken for swallowed code and stays refused. ### Tested Whole pipeline library (1.0.2.1, own copy), all 2,684 compute programs, llvm-mc 21.1.8, `--wave64-emulate`, `main` + #596 without and with this commit: | | #596 | + this | |---|---:|---:| | translated | 1,816 | **2,567** | | pass `spirv-val` | 1,816 | **2,567** | | "fall-through into undecodable words" | 833 | 3 | 0 programs lost, and the 1,816 modules are byte-identical. What is left: 80 `s_load_dword*` with a `vcc` base or destination (#647 has the bases), 18 `s_flbit_i32_b64` and 6 `s_bitreplicate_b64_b32` (#593), 9 that cannot be re-anchored, 3 fall-throughs, 1 `s_sethalt`. The 26,503 main-corpus listings have no undecodable words with this disassembler, so this path does not run on them. - `tests/semantic/test_vcc_tuple_fallback.py`: 7 tests pass; the new case is red without the fix, and a second one checks that a rejected word after a tuple is still refused. - Whole translator suite: 466 files, 6,115 tests, all pass but `test_image_cube_store_glc`, which fails here with `FileNotFoundError` starting an external program, on `main` too. - The `tests/test_docs_*.py` set, `test_text_write_line_endings.py`, `compileall`, `check_no_game_data.py`: clean. The new modules are checked by `spirv-val` only; none was compared with hardware. GPUs tested: n/a AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:48 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#713
No description provided.