tools: decode the pipeline-library compute programs llvm-mc refuses #998
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!998
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/998/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Kokonotcu on GitHub · 2026-11-24 16:42 UTC · original
Kokonotcu:fix/library-compute-decode→main· +190 −25 · 8 files · 3 commits · merged 2026-11-26 03:08 UTCllvm-mc 21 cannot decode SMEM loads whose SOFFSET is null (0x7D). Because of that, whole pipeline-library compute programs of 1.0.2.1 disassembled with invalid words and failed to translate. A retail boot also reached 50 more library programs that had no translation; dumped from the running game, all 50 now translate and pass spirv-val.
Changes
compute=True, passed by shader_library and fspx_unpack), it falls back tordna2_decode.disasm_byteswhen that leaves fewer invalid words than llvm-mc.--last-endpgm: early exits branch past the first s_endpgm, and data after the code can hold s_endpgm words, so a program ends at the first s_endpgm whose listing keeps every branch inside the code.vccas its base reads the vcc_lo/vcc_hi pair.s_flbit_i32_b64of a lane mask reads the wave's 64-bit mask (18 library programs), ass_ff1_i32_b64already does.s_bitreplicate_b64_b32of a lane mask into plain scalar data replicates the wave's mask word (6 library programs). From a constant into vcc it sets each lane's bit as the exec form does (6 programs).v_cmp_*_dppinto vcc (12 compares in reductions) is taken when every lane writes (full row/bank masks with bound_ctrl:1, or DPP8).test_salu_flbit_64: the lane-mask case now translates; the subgroup op is outside the single-invocation interpreter, so the test checks that.test_fspx_unpack: the invalid-word case takes the decoder's listing; new cases cover the two-word prologue,code_range_lastand branch checks.test_salu_quadmask_bitreplicate: new case for bitreplicate into vcc.Result
Library programs: 2633 of 2684 translated after the first commit; the 50 the retail boot then dumped as missing all translate after the second.
Testing
These pass:
tests/semantic/test_salu_flbit_64.pytests/semantic/test_salu_quadmask_bitreplicate.pytests/test_fspx_unpack.pytests/test_shader_library.pytests/test_rdna2_decode.pytests/test_shader_disasm.pytests/test_rdna2spirv_decode.pyThe VOPC-DPP path is checked only by spirv-val, since the interpreter runs no subgroup ops. Tested on an RTX 3080 Laptop, i7-11800H, Windows 10.
🤖 Generated with Claude Code
@Dezmonius on GitHub · 2026-11-24 19:06 UTC · original
Independent check of head
bec14f225on Windows 10 22H2, i7-7700K, RTX 5070 / NVIDIA 610.88, LLVM 23.1.5, Vulkan backend.I matched the three slot-67 failures in a local DadaCap
boot-prototyperun (9173e790) to three programs absent from its translated library. The baseline listings each contained seven invalid words. With the PR head's decode/translation tools, all three disassembled with zero invalid words, translated with wave64 emulation, and passed spirv-val.On the same runtime, supplementing the shader index with only those three translations removed the three slot-67
E_INVALIDARGfailures. Both runs reached Vulkan presentations and reproduced the same later title exception at+0xb5a5f8reading0x68; the captured frames were black.The PR head's
test_fspx_unpack.py,test_shader_disasm.py, andtest_rdna2_decode.pypassed (85 passed, one skipped). No game data, shader binaries, disassembly, captures, or raw logs attached. AI-assisted (Codex).@bobcatchris on GitHub · 2026-11-25 00:45 UTC · original · reviewed
Reviewed
bec14f225on a second vendor and LLVM version: Windows 11, LLVM 21.1.8, Python 3.12, an AMD Radeon RX 7900 XTX in the box but no GPU work. AI-assisted.Tests. The seven files you list pass (145 tests).
Rebase. It is 257 commits behind
main(507029d1e) and conflicts in two files. Both conflicts are in codemainalready has from the VOPC-DPP change: the compare-with-DPP-src0 block intools/rdna2_decode.py, and thecomparebranch of the DPP path intools/rdna2spirv.py. I mergedmainin locally and tookmain's side of both. That leaves yourrdna2_decode.pyidentical tomainand your diff at 7 files, +154/−23. One trap: yourself.dpp_guard = None if lane_mask_dst else writemerges cleanly, butlane_mask_dstis then defined nowhere, andmainalready returns before that line for compares. It should go back toself.dpp_guard = write; left as it is, every DPP instruction that is not a compare raisesNameError. With that, your seven files plustest_dpp_compareandtest_dpp_eager_subgrouppass (161 tests).Coverage. The first 700 compute programs of the 1.0.2.1 library in index order,
--wave64-emulate, each tree with its own listing path:spirv-valmainmainmainare 90fall-through into undecodable words, 6undecodable words (cannot re-anchor), 4s_flbit_i32_b64 of a lane maskand 1s_bitreplicate_b64_b32 on a lane mask.maintranslates is lost. 592 of the 599 shared modules are byte-identical. The other 7 (lib_cs_00857tolib_cs_00867) differ only by two or threeOpAccessChaineach: they holds_bitreplicate_b64_b32 exec, IMM, which is theexecpath you changed, so this is a behaviour change for programsmainalready translated.The stated cause. The docstring says llvm-mc 21 does not decode SMEM loads whose SOFFSET is null. On 21.1.8 it decodes those:
s_load_dwordx8 s[16:23], s[2:3], nullassembles and disassembles. What it rejects is a scalar register tuple that reachess106/s107:s_load_dwordx4/x8/x16with its data ats[104:107],s[100:107]ors[96:107];s_buffer_load_*with its four-register descriptor ats[104:107];s[104:107].In the 115 flagged listings I had at the time, the 40 most common shapes of the rejected words come to about 3,200 of this kind against 37 of any other. Your fix covers them either way, because the decoder prints the
[s100,...,vcc_lo,vcc_hi]formshader_ir.pyalready reads. The comment should name the tuple, so that the rule says how it was confirmed.One decision to make in the open. On a program that takes the fallback, the listing's encodings are the code bytes (
finish()storescode[pc:pc + nbytes]), socheck_printed_encodingscan no longer see a word llvm-mc would have printed differently; and the decoder does not check must-be-zero bits. I flipped every bit of a set of reference instructions and compared the two decoders. Where llvm-mc rejects or renormalises a flip, the decoder returns the same instruction for the scalar-memory reserved bits (w013, 15, 17 andw121 to 24) and for DPP16w1[17].w1[17]is set in 24 instructions of 4 programs:lib_cs_21476,lib_cs_21500,lib_cs_21520,lib_cs_21521.maintranslates 1 of those 4 and refuses 3. With this PR all 4 translate, with the bit read as clear.mainrefuses a reachable word of that kind, so this changes the policy for those programs. Either is defensible, but I think it should be a choice in the PR and not a side effect of the fallback. The smallest options are to have the fallback listing count such words and refuse, or to write the choice into the contract table.Contract table. The PR changes two rules that
docs/design.mdstill describes the old way. Thes_flbit_i32_b64row says a pair thatlane_masks.pymarks as a lane mask staysUnsupported. Thes_quadmask/s_bitreplicaterow says a lane-mask source or an EXEC/VCC destination raisesUnsupported. Neither row is updated, and the fallback listing is a third rule without a row.Not run. No translated program on a GPU.
--last-endpgmandbranch_closed_endonly throughtest_fspx_unpack.py. The other 1,984 programs are not compared yet; I will add the full-corpus count when I have it.Recommendation: Fix first. The rebase and the contract rows; the rest as you decide.
@bobcatchris on GitHub · 2026-11-25 01:53 UTC · original
Full-corpus numbers, as promised: all 2,684 compute programs of the 1.0.2.1 library,
--wave64-emulate, LLVM 21.1.8, each tree with its own listing path.mainat507029d1e; this PR merged on it with the two conflicts resolved as in my review.spirv-valmainmainmain(996): 942fall-through into undecodable words, 20branch into data, 18s_flbit_i32_b64 of a lane mask, 9undecodable words (cannot re-anchor), 6s_bitreplicate_b64_b32 on a lane mask, 1reachable instruction with normalized encoding.s_sethalt, inlib_cs_21475, a program of 14 instructions.main. 923 of them take the decoder listing, 50 get a different code range (the shorter prologue, so they go throughdisasm(compute=True)afresh), and 21 of those 50 still carry invalid words. The other 1,711 listings are unchanged.maintranslates also translate with the PR. 1,678 modules are byte-identical. The 10 that differ are 9 that holds_bitreplicate_b64_b32 exec, IMM(lib_cs_00857tolib_cs_00867, pluslib_cs_01990andlib_cs_02039), andlib_cs_21521, whose range now starts after the 24-byte prologue wheremainlisted from offset 0.Correction to my first review. Its 700-program sample was the first 700 in index order, and that is not a fair sample: the programs with rejected words cluster by index. Per decile of the 2,684, 18, 41, 100, 146, 73, 144, 197, 133, 46 and 25 are flagged. The sample showed 14% of programs refused; the whole corpus is 37%.
Order of merging. #623 hands llvm-mc its input in 64-byte lines. With
main's single line the listing step echoes the whole program before every warning: on this package it wrote 8.9 GB for its first 170 flagged listings and stopped with no space left on the drive. With #623's input the same 2,684 listings take 96 seconds and 1.5 GB, with byte-identical listing text. The two PRs touchtools/shader_disasm.pyin different places (run_mcandINVALID_ATagainstdisasm), so they should merge independently; whoever lands second will want to re-run the count.Still not run: nothing on a GPU, and
--last-endpgm/branch_closed_endonly throughtest_fspx_unpack.py.@bobcatchris on GitHub · 2026-11-25 02:22 UTC · original
GPU results, to close the "not run" line from my review: I built this PR's runtime test runners (RelWithDebInfo, MSVC 19.39, Ninja) and ran the GPU shader suite on the machine from my first review — Windows 11, AMD Radeon RX 7900 XTX (gfx1100), driver 26.10.1, Vulkan SDK 1.4.341. AI-assisted.
LEONIDA_W64_EMULATE=1The two failures are
cs_imgload_tfeandcs_imgload_d16_tfe: on the r32 sint view all 64 texels are bad,texel(5,3) = 2071where 71 is expected — exactly +2000, the two status VGPRs keeping their seeded 1000, so the TFE fetch status is not delivered on this driver.They are not from this PR. I built the merge-base
82a2aabccthe same way and ran the suite: native passes and fails the same 234 and 2, with the same 2071.What this adds to the review: the ops the PR changes are covered by fixtures that passed on the 7900 XTX in both modes, including
cs_w32_new_ops(thes_bitreplicate_b64_b32expected words from the contract table), the tencs_dpp*fixtures andcs_w32_salu64. Thes_flbit_i32_b64ands_bitreplicatelane-mask paths the PR newly allows are still onlyspirv-val-checked, since no fixture exercises them yet — that part of my "not run" stands.Separately, and good news rather than a tracker item: the same two fixtures pass on
cdb003ea1, the tree my 2026-11-24 session measured (236/252 there, zero failures), and this PR's base is an ancestor of that tree (251 commits behind it). So the TFE fetch status already has a fix on newermain, the failures above are only the 257-commits-stale base, and the rebase this PR needs anyway will pick the fix up. Nothing to do here.@bobcatchris on GitHub · 2026-11-25 04:08 UTC · original
I rebased the three commits onto current
main(f78385646) and tested the result end to end, because the review said "rebase first" and the base had grown 257 commits past what the measurements ran on. The branch is on my fork asbobcatchris/Leonida@pr-998-rebased— four commits: your three, then one commit of mine that carries the conflict resolutions (clearly attributed, AI-assisted). Squash or cherry-pick from it as you prefer; I did not touch your PR branch.What main landed since your base, and how the conflicts resolved
d04655943(SHADER-VOPC-DPP, #957): the VOPC-with-DPP decoder words your first commit adds. Taken frommain; your decoder change is redundant.1ea2ffbca:s_flbit_i32_b64of a lane mask (wave64) and bitreplicate into EXEC/VCC (VCC wave64 only) via amask_dsthelper. Keptmain's forms; kept your wider constant-to-VCC rule, because the six pipeline-library programs that use it are wave32, whichmain's restriction refuses — my commit restores your behaviour withmain's store helper.ce98fbefe: restores vcc-tuple words into the listing from the blob. Not enough on its own (see below); your listing-level fallback stays the thing that closes the gap.TOOLS-DISASM-WAVE-SIZE(#1282):wave32=threading throughdisasm. Combined with yourcompute=True.mainalso gained its own two-carrier prologue detector (fspx_prologue_probe), stricter than yours. Tookmain's; yourtest_two_word_prologuefixture needed its second VOP3 word changed to the probe-validated0x03FE0100shape to match.dpp_guard = None if lane_mask_dst else writeline merges silently and then breaks every non-compare DPP instruction (lane_mask_dstno longer exists). If you rebase by hand, that line goes back toself.dpp_guard = write;mainreturns before it for compares.Verification, all on the rebased branch
--wave64-emulatespirv-val(onlys_sethaltrefuses) — same as your PR head's numbersLEONIDA_W64_EMULATE=1The corpus number is the headline:
mainat the same commit translates 1,688 of 2,684. The 995-program gap survivesmain'sce98fbefe, so your listing-level fallback remains the fix that matters.On the GPU suite: the one failure is
cs_imgatomic_ext(6 of 64 sint words hold the0x0badf00dsentinel). I built plain currentmainand ran the same fixture: identical failure, so it is pre-existing onmainand not yours — a new main-side gfx1100 regression relative to the 2026-11-24 run, unclaimed as far as I saw.cs_imgload_tfe/cs_imgload_d16_tfenow pass, confirming the TFE fix I inferred last comment.cs_texture_uavneededd3d12_texture_uav_testbuilt withcl+ vcvars (my earlier run only lacked the binary); it passes.Still only
spirv-val-checked: thes_flbit_i32_b64/s_bitreplicatelane-mask-source paths — no fixture exercises them yet.Not pushed to your branch, not merged, and nothing dispatched in the title. Build note for reviewers on Windows: configure with
cl.exeunder a Developer Prompt; my first configure here picked ROCm'sclang++.exeand mis-built the d3d12 runners silently.