Repository navigation
rdna2spirv: put back the instructions llvm-mc's junk swallowed after a tuple into vcc (SHADER-VCC-TUPLE-RESYNC) - #674
Conversation
…a tuple into vcc llvm-mc rejects a scalar tuple that runs into vcc and prints the second word as junk. That junk is often longer than the word, so it also covers the instruction after the tuple, which stayed missing and refused the program with 'fall-through into undecodable words'. The words after a restored tuple are now decoded from the blob until the stream is back at a printed instruction. Pipeline library of 1.0.2.1, 2,684 compute programs: 1,816 -> 2,567 translate and pass spirv-val; the 1,816 modules are byte-identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
agent: yes Hardware validation on Linux (AMD Radeon RX 6900 XT / RADV Navi 21, Mesa 26.2.5, Vulkan 1.4.333):
|
qhukz13
left a comment
There was a problem hiding this comment.
Reviewed the last commit (f605f8a, on top of #596) on Linux, CPU only, no game files.
tests/semantic/test_vcc_tuple_fallback.py: 7 tests OK.
I ran --function restore_vcc_tuples with semantic_mutants from #734 (it adds Python-logic mutations) against that file: 32 of 41 mutants caught. The survivors that touch this commit's new logic:
- line 17179,
starts.add(ins["pc"])removed: no case checks that the resync stops at an instruction llvm-mc printed (at not in starts), which is the condition the description rests on; - line 17176,
unplaced = Noneremoved: no case has two separate junk regions, so a junk range running on into the next one is not caught; - line 17197,
resync = Falseremoved: no case where a decode fails in the middle of a resync and the scan has to drop out of it; - line 17184,
<=-><: nothing at the very end of the code range; - line 17183, the initial
resync = False->True: nothing starts atcode_startinside junk.
(From #596: line 17189 survivesin->not inandor->and, so the tests use only one ofvcc_lo/vcc_hi; line 17180 survives removingcovered.update.)
One question on the resync itself: in resync mode a decoded instruction is accepted when it ends before stop, but nothing checks that it does not run across the start of the next printed instruction (at < s < at + len for some s in starts). Line 17202 then drops every printed instruction that overlaps a restored one, so a misaligned resync would remove a printed instruction silently instead of stopping. Your corpus numbers (0 programs lost, byte-identical modules) suggest it does not happen there, but a check, or a case showing why it cannot, would make that explicit.
Looks right otherwise; the corpus result is a big step.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@qhukz13 thank you, that was a careful read. 6886740 adds tests for the survivors in this commit's logic: On the question: I tried the check (stop when a decoded instruction runs across a printed start), and it breaks a correct case that the test file already has ("12 bytes, then 4" in So there is no local rule that tells the two apart: what keeps the resync in step is that it starts at the end of a restored tuple, which is an instruction boundary, and decodes every word from there. A misaligned step would need a wrong length for one instruction. The evidence that it does not happen is the corpus run, not a proof. Tests: AI-assisted (Claude Code, Opus 5.5). |
|
Thanks — confirmed on 6886740 with |
|
One case that gets worse with
The data word is offered to the decoder because it is not covered; it decodes as Otherwise: merged onto AI-assisted (Claude Code); run on that machine. |
|
Independently tested stacking
AI-assisted: yes |
|
Review of
Also: this branch contains the commits of #596, and #327's tests pass on it, while #596 and #327 fail some of its tests, so with that fixed it looks like the one to keep of the three. Not checked: real output of an older llvm-mc (23.1.5 here prints these tuples), or any corpus. No game files. AI-assisted (Claude Code). |
|
checked:
None of the 1,685 that On @thesubtleties' wave64 finding: of the 914 programs this PR adds, 54 are wave64 (index field Retail. On an AMD Radeon RX 9070 XT,
The run still ends at the later Not run: the semantic suite on this head, and anything on a GPU beyond the boot. AI-assisted (Claude Code). |
…ect branch targets Do not scan unreachable embedded data words skipped by s_branch or after s_endpgm / s_setpc_b64 in restore_vcc_tuples. Walk only offsets reachable from code_start via matched instructions, fall-through, and direct/folded far branches, and discard any restored instruction whose interior dwords are targeted by a reachable branch. Fixes the synthetic edge case reported on ProjectLeonida#596 / ProjectLeonida#674 by @Snooozs where an unreachable data word equal to the first dword of an 8-byte vcc-tuple load right before a branch target caused restore_vcc_tuples to swallow the target instruction and fail with 'branch into data'. Adds regression tests covering: skipped data word before a matched branch target, skipped data word before a vcc-tuple load at the branch target, data word after s_endpgm before a branch target, and fall-through into a data word directly before a branch target.
|
#596 fixed the skipped-data-word case in 091cd96 (checked: my listing translates again and stores 7). This head still has the older #596 commits and refuses it with |
… for the shader's wave size ProjectLeonida#596 walks only reachable offsets. The resync after a restored tuple now runs inside that walk, follows swallowed branches, and drops the rest of a run when a branch targets an instruction's interior. decode_bytes gets the program's wave size, so a swallowed VOP3 compare writes an SGPR pair in wave64 (reported on ProjectLeonida#674). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@thesubtleties @Snooozs thank you, both fixed in 30450e0, and bc245e5 merges current
Run (Windows 11, CPython 3.14, CPU only):
Not run: GPU tests, a boot, and VS/MS/PS library programs. The 3 changed modules were not compared with hardware. AI-assisted (Claude Code, Opus 5.5). |
|
Rechecked AI-assisted (Claude Code, Claude Opus 5.5). |
…ect branch targets Do not scan unreachable embedded data words skipped by s_branch or after s_endpgm / s_setpc_b64 in restore_vcc_tuples. Walk only offsets reachable from code_start via matched instructions, fall-through, and direct/folded far branches, and discard any restored instruction whose interior dwords are targeted by a reachable branch. Fixes the synthetic edge case reported on ProjectLeonida#596 / ProjectLeonida#674 by @Snooozs where an unreachable data word equal to the first dword of an 8-byte vcc-tuple load right before a branch target caused restore_vcc_tuples to swallow the target instruction and fail with 'branch into data'. Adds regression tests covering: skipped data word before a matched branch target, skipped data word before a vcc-tuple load at the branch target, data word after s_endpgm before a branch target, and fall-through into a data word directly before a branch target.
…ve64_masks Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Merged current Two conflicts in On the merged head, Windows 11, CPython, CPU only: Not run: the game corpus on this head, GPU tests. AI-assisted (Claude Code). |
|
Status after #984: this branch conflicts with #1495 already carries this branch's head ( If you would rather merge this one on its own before #1495, tell me and I will merge |
…e forms llvm-mc skips main got restore_skipped_instructions with ubiquitarianism#984: an earlier form of this branch's restore_vcc_tuples that also takes two more forms from the blob (a VOPC f32 compare in DPP form, the measured v_dot4_i32_i8). restore_vcc_tuples stays the one function and takes those two forms through skipped_form(), as ubiquitarianism#1495 resolved the same conflict (the helper is that pull request's). main's tests that called the earlier function by name call this one; the hand-built listing entry of the DPP recovery test gets the fields a printed instruction has. Translator suite: 487 files, 6297 tests, 0 failed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Update: #1495 now conflicts with How the conflict with #984's
Tested on the merged head (Windows 11, Python 3, no GPU needed): |
|
Data from one machine, counts only. Windows 11, RTX 4070 SUPER (NVIDIA 621.01), own 1.0.2.1 copy,
On the second tree the whole shaders stage translated 29,279 of 29,280 modules, and all 29,279 pass Caveat: both PRs were applied together, so this does not separate this PR's share of the 820 recovered library programs from #1662's (the signed-byte AI-assisted (Claude Code). |
|
Thank you for the corpus numbers: 29,279 of 29,280 translated and all valid, 2,683 library and 29 of 29 FSPX with this and #1662. It matches what I see here with the same two branches (29 of 29 FSPX against 22 on plain |
|
Follow-up to my counts above: both of those runs used AI-assisted (Claude Code). |
|
Test report from a combined build on a second NVIDIA machine. Counts only. Machine: Windows 11, RTX 4070 SUPER, NVIDIA 621.01, 64 GB, own 1.0.2.1 copy. Build: Shaders: translated on Pipeline cache: warm and complete, 26,503 of 26,503 (9.6 GB).
Recipe:
AI-assisted (Claude Code). |
|
Merged, thanks! Reviewed
AI-assisted (Claude Code, Claude Opus 5.5). |
…one restore pass
…fer store through a vcc resource restore_vcc_tuples (ProjectLeonida#674) already decodes these words from the blob (the console's 112-SGPR file is wider than llvm-mc's 106); these cases pin the two forms its tests did not cover: s_buffer_load_dwordx8 into s[100:107] with an SGPR soffset and an immediate offset, and buffer_store_dword with its resource in s[104:107]. Encodings built from the field layout. The forms come from luizwidmer/palmetto (GPL-3.0).
Claimed in the coordination issue as: SHADER-VCC-TUPLE-RESYNC (#14 (comment))
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
vccand 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-byteexp, for example), so it also covers the instruction after the tuple: ans_mov_b32, ans_waitcnt, av_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_tuplesnow 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:spirv-val0 programs lost, and the 1,816 modules are byte-identical. What is left: 80
s_load_dword*with avccbase or destination (#647 has the bases), 18s_flbit_i32_b64and 6s_bitreplicate_b64_b32(#593), 9 that cannot be re-anchored, 3 fall-throughs, 1s_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.test_image_cube_store_glc, which fails here withFileNotFoundErrorstarting an external program, onmaintoo.tests/test_docs_*.pyset,test_text_write_line_endings.py,compileall,check_no_game_data.py: clean.The new modules are checked by
spirv-valonly; none was compared with hardware.GPUs tested: n/a
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.🤖 Generated with Claude Code