Repository navigation
Conversation
…d shows the literal as an exp (SHADER-804) LLVM 21.1.8 cannot decode v_pk_* / v_fma_mix* with a 32-bit literal: it prints an invalid word and reads the instruction's second word and the literal as other instructions, an exp when the literal's top byte is 0xF8..0xFB. 22.1.8 and 23.1.6 decode them. shader_disasm and fspx_unpack --disasm now stop, naming the version, when a packed literal is lost; docs, CI and build_llvm_mc.ps1 move to LLVM 22.
…l packed-literal decode test, testing.md on LLVM 22
kacper-serewis
left a comment
There was a problem hiding this comment.
At 401ac9c, LLVM 22.1.2 passes the new preflight but all five affected FSPX programs still fail via the normal entry point. All 29 cached exports were freshly disassembled for gfx1030. LLVM 22.1.2 translated and validated 21/29; diagnostic LLVM 21.1.8 (preflight bypassed) and the historical cache both gave 22/29. One additional program fails printed-encoding parity on 22.1.2. Please narrow the version claim and verify any proposed floor against the affected programs. This does not establish the minimum working version. AI-assisted CPU review.
|
A no-regression check with llvm-mc 23 (I have the DLL, not llvm-mc 21), on my own 1.0.2.1 copy, Windows,
So under LLVM 23 the change is a no-op for these programs, as it should be. The remaining 3 failures are the ones LLVM 23 already had (03 and 18, the |
kacper-serewis
left a comment
There was a problem hiding this comment.
SHADER-804 follow-up at 401ac9c on the same 29 cached FSPX exports through the normal pipeline. LLVM 22.1.8: 29 listings, 322 invalid words in 11 listings, 21 translated and Vulkan-valid. LLVM 23.1.6: 29 listings, 89 invalid words in eight listings, 26 translated and valid. It retained every 22.1.8 success. This directly checks the requested 22.1.8 release; 23.1.6 is the better of the tested versions, and three programs remain unvalidated. AI-assisted CPU only.
|
Thanks @kacper-serewis, that is a real gap in my claim: I measured the packed-literal decode on hand-built words with 22.1.8 and 23, never on 22.1.2 or on the real programs. I will (1) find the LLVM change that fixed VOP3P-with-literal decoding and the first release that has it, (2) run the probe words through every 22.1.x I can get, and (3) make the floor whatever that shows (a point release, or 23) with the probe checking the exact behaviour rather than the major version. Could you share which instruction the five programs fail on under 22.1.2 (the line before the |
…gs (SHADER-804) The FidelityFX FSPX programs encode unused VALU source fields as 0x80 (inline 0). LLVM 21 and 22.1.0 reject those words and misread the rest (the literal 0xfbff3c00 as an exp). 22.1.1 to 22.1.8 decode them but print the field as 0, so the printed-encoding check refuses the listing, and print a float inline constant in a 16-bit integer operand as a 12-byte literal. 23.1.0 has both fixes (llvm-project ef0680ba54f7, d7ee01c0fa31); no 22.x release has either. shader_disasm.py now decodes one instruction per family in one cached llvm-mc run and refuses any whose printed encoding is not its input, naming the version, each family and the release that fixes it. Docs, i18n quickstarts, CI (llvm-23), build_llvm_mc.ps1 (23.1.6) and the preflight messages say 23. Tests: fakes answer the check as measured 21.1.8, 22.1.2 and 23.1.6 did; the real-llvm-mc test expects refusal before 23.1.0 and exact listings from it.
… test fake answers the check (SHADER-804) make_game.py signs a disassembly with the llvm-mc command, its --version output and DISASSEMBLY_CHECK, the revision of shader_disasm.py's decoding check. A work folder disassembled before the check (e.g. by LLVM 22.1.2) no longer matches, so its listings are redone and the check runs. test_fspx_shaders_stage's retried-disassembly fake now answers the check as LLVM 23.1.6 does (fake_llvm_mc.GOOD), so it fails and passes for its own reasons again. Bug report placeholder names LLVM 23.1.6.
|
@kacper-serewis thanks, you were right: no 22.x is enough. Head is now
The probe now checks exactly those families with 3 instructions, and it refuses every 22.x. A work folder disassembled with an older llvm-mc is now disassembled again. Your 23.1.6 result (26/29, keeping every 22.1.8 success) matches. The remaining three (03, 18, 27) are outside this PR. One lead for one of them: |
|
Data point from the retail The five programs' invalid words are not VOP3P-literal words. I took every
Zero Example, program 05 at 0x2120: blob Hand-built check, no game data: Even with 23.1.6 listings,
Programs 07, 08, 28 come out identical under both (the SMEM class was their only loss); program 00's python-backend module is 48 asm lines shorter than the llvm-mc one, a decode-format edge I did not chase. With python-backend listings for all 29 programs, So the floor bump is still worth having (it removes the SMEM class and the junk AI-assisted (omp orchestrator). Retail DLL read-only; counts and synthetic encodings only, no game data committed. |
|
Thanks @abilliontokens, this corrects my explanation. The The floor stays 23, for this reason first. The VOP3P I am adding that SMEM shape to the decoding check, so the error names it, and correcting the design table and the description, with credit to you. The 87 |
…PX exp (SHADER-804) abilliontokens classified the 322 words llvm-mc 21.1.8 rejects on the real FidelityFX DLL: 233 are scalar and buffer loads whose register list runs past s105 into vcc_lo/vcc_hi, 87 v_dot4_i32_i8 op_sel words (also undecodable on 23), 2 others, and no v_pk_*/v_fma_mix literal. The junk exp in programs 05, 06, 08, 09 and 28 is the scalar load's second word. Measured on conda-forge llvm-tools: 21.1.8, 22.1.0, 22.1.2 and 22.1.8 all reject 16 17 30 f4 70 d0 01 fa; 23.1.0 and 23.1.6 decode it. The fix is llvm-project 1cd28beb7755 (#173870), first in llvmorg-23.1.0-rc1. require_exact_decoding now sends that scalar load first, among the four checks in one cached call, and matches the output to the checks by byte offset (invalid-word columns and printed lengths), so the error names the scalar load first and still reports the families after it, or says that the misread ran into them. fake_llvm_mc.py replays the measured 21.1.8, 22.1.2 and 23.1.6 outputs; docs/design.md and testing.md name the scalar loads as the cause and keep the VALU families as further reasons for 23.
|
Pushed
One detail: on 23.x your hand-built |
|
Tested Their own tests run here — the six
212 tests, 0 failures. The new Translator suite (the 28 pytest-marked files, as CI runs them): branch 1637 passed, 37 skipped, 108 subtests passed — identical to Merged state (this branch's base
The floor, measured on the distro
What the floor does not gate on this machine: Second card: the RTX 5080 in this box is holding other work right now, so it was not launched this pass — no second-card number, and that is not a failure. |
|
Thanks @chpeu. Your LLVM 20.1.2 run is a useful extra point below the floor. On On who gets stopped: yes, that is deliberate. The GPU battery assembles its own fixtures and does not depend on the disassembler. Only the listing and |
|
Tested 3195640 on CachyOS Linux with the real llvm-mc (LLVM version 23.1.5), CPU only: pass.
The PR text names PackedLiteralTest; at this head the class is DecoderCheckTest. Real llvm-mc 21 and 22 were not run here. AI-assisted. |
|
Code read + CPU tests, 3195640: pass ( The LLVM 21/22 misdecode of scalar loads into VCC is the kind of thing that only shows as a wrong instruction later, so pinning the minimum to 23.1.0 with this test is worth the inconvenience. Note this box runs LLVM 21.1.8, so the tests pass because the version gate refuses to use it — which is the intended path. |
|
Tested 3195640 merged with main 3faac55 on Windows 11 native with Python 3.13.1 and 3.12.16 (real llvm-mc 23.1.6 with the AMDGPU target) and on Linux (WSL2 Ubuntu, kernel 5.15) Python 3.12.16 (no llvm-mc there, fake_llvm_mc only): pass.
|
|
Tested
Not run: llvm-mc 22.x and 23.1.0/23.1.6, Windows ( Synthetic inputs only, no game data. AI-assisted. |
|
Verified against main 3faac55: merges cleanly; compileall passes and all changed suites (test_shader_disasm 29, test_fspx_unpack, test_fspx_shaders_stage, both preflight tests, test_shader_stage_resume) pass under python -I. The new decoding gate was executed here against host llvm-mc: it passes silently and decoder_faults reports nothing, matching the stated minimum. The LLVM 21/22 misdecode evidence cannot be reproduced on this host (no 21/22 builds); fixtures are hand-written words, no corpus data. The branch currently reports no CI checks — please re-trigger. Two reviewer notes: it collides with #4845 in the same testing.md paragraph (verified conflict), and pending #4204 pins LLVM 21 in a Runtime workflow, which is a policy direction this PRs 23.1.0 minimum should agree with. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
|
Thanks @memorypressure. On your two notes:
CI on fork PRs runs once a maintainer approves the workflow run, so I can't re-trigger it from here. |
… LLVM 23+ requirement
|
Tested
|
|
Thanks @KkelebekK. Commit 1e5f42b fixes the sentence below the LLVM 23+ line in docs/testing.md. It now says an older llvm-mc is not enough for the disassembly tools but still runs run_gpu_tests.py, the mem fuzzer and lds_fuzz.py (the llvm-18 case). Docs only, nothing to run. AI-assisted. |
VeTkN
left a comment
There was a problem hiding this comment.
Tested 3195640 on the machine where SHADER-804 was found: Windows 11 Pro 26200, Visual Studio 2026 Build Tools 18.10 (MSVC 14.51.36231), Python 3.14.7, SPIRV-Tools v2026.4, my own 1.0.2.1 FidelityFX DLL: pass. The refusal, the 23.1.6 listings and the three leftover programs were re-checked on the current head 1e5f42b, with the same results.
- scripts/build_llvm_mc.ps1 -NoEnv -Dest : built llvm-mc 23.1.6 (1,035 build steps) with VS 2026 in 8 minutes, source clone included, exit 0.
- fspx_unpack.py --disasm with the real llvm-mc 21.1.8: refused (exit 1, no listings), 4 families named, the scalar load into vcc_lo/vcc_hi first, and "Use LLVM 23.1.0 or newer".
- The same with the new llvm-mc 23.1.6: accepted, 29 listings.
- rdna2spirv.py --wave64-emulate (this head's translator) on the 29 programs: 22 translated and valid from my 21.1.8 listings (made yesterday, before this check existed), 26 from the 23.1.6 ones. 05, 06, 08, 09 and 28 now translate.
- The three left with 23, each translated alone: 03 and 18 stop with "reachable instruction with normalized encoding"; 27 stops at a v_fma_mix_f32 whose printed encoding lacks a field the disassembler dropped, so not at a v_dot4 word. 27 was valid from the 21.1.8 listings.
- test_shader_disasm.py (29) and test_fspx_unpack.py (28): OK with both real llvm-mc builds.
Both 3195640 and 1e5f42b conflict with main 561b65a, in docs and CI only: .github/workflows/ci.yml, README.md, docs/testing.md and six docs/i18n quickstarts.
Counts only, no game data.
AI-assisted (Claude).
|
Row for a machine below the new minimum: this box runs What still runs here, end to end:
So the LLVM 23 floor does not come from anything that breaks the existing programs on an LLVM 20 box: the whole One thing the PR still needs before merge, from this side: the branch no longer merges cleanly onto current Machine: Linux Mint 22 (Ubuntu 24.04 base), LLVM 20.1.2, SPIRV-Tools 2025.1~rc1, GCC 13.3, Python 3.12.3 with pytest |
…d apt key-check text; require LLVM 23 (llvm-23, noble-23) where main still said 21
|
Thanks @chpeu. That matches the intent: LLVM 23 is the floor for the disassembly tools ( |
|
Follow-up on the merge problem I reported this morning: at the new head
Scope of this note: it is a merge-and-Python check. My GPU row for this PR (201/217 with |
|
Tested
AI-assisted (Claude Code). |
…nd tr quickstarts, with llvm-23)
|
Tested 94e3c87 merged with main 8575d36 on Linux (WSL2) / Python 3.12.16: concern |
Claimed in the coordination issue as: #4683 (comment)
Update (after review): the floor is LLVM 23.1.0, not 22
kacper-serewis measured that 22.1.2 and 22.1.8 still fail the five programs, and abilliontokens found why on the real DLL. Both were right, and my first explanation was wrong.
The cause of the five programs'
exp(thanks to abilliontokens). They classified all 322 invalid words that llvm-mc 21.1.8 reports on the 29 programs:s_buffer_load_dwordx16, 3s_buffer_load_dwordx8/x4and 10buffer_load/store_dwordx4whose register list runs past s105 intovcc_lo,vcc_hi(programs 03, 05, 06, 07, 08, 09, 28).v_dot4_i32_i8words withop_sel, which 23.1.6 cannot decode either (rdna2spirv: v_dot4_i32_i8's op_sel/op_sel_hi come from the blob when llvm-mc drops them (SHADER-626) #3372 / rdna2spirv/fspx_unpack/make_game: direct binary RDNA2 decode backend (#1901) #2323 scope; rdna2spirv: a reachable fall-through into undecodable words is refused, not a silent end of the path (SHADER-813) #4595 refuses a reachable fall-through into them).v_pk_*orv_fma_mix*word with a literal.The junk
expright after each invalid word in 05, 06, 08, 09 and 28 comes from the scalar load. Program 05 at 0x2120 has16 17 30 f4 70 d0 01 fa. 23.1.6 reads it ass_buffer_load_dwordx16 [s92..s105,vcc_lo,vcc_hi], s[44:47], 0x1d070. 21.1.8 reads it as an invalid word, thenexp mrt7. That also accounts for 322 against 89: the 233 vcc-tuple words decode on 23, and the 87 + 2 stay.Which versions decode that scalar load (measured on a pod, gfx1013 and gfx1030):
16 17 30 f4 70 d0 01 faThe fix is llvm-project
1cd28beb7755(#173870, "Have VCC as a first-class member of the SGPR pool"). It is in llvmorg-23.1.0-rc1 and later, and in no 22.x tag. So 22.x can never be enough for these programs.Further reasons for 23, from a sweep of about 580,000 encodings with llvm-mc 21.1.8, 22.1.0, 22.1.1, 22.1.2, 22.1.8, 23.1.0 and 23.1.6. The sweep covered every VOP3P and VOP3 opcode for gfx1010 and gfx1030, literals in each source slot with each modifier, inline constants, unused source fields of 0 and
0x80, and 200,000 random words:0x80(as LLVM 23's assembler writes it)v_add_nc_u16 v0, 0.5, v2)Those fixes are
ef0680ba54f7(#175753) andd7ee01c0fa31(#200944), also only in 23. 22.1.1 got only the decode half of the first (8099e127cde2, backported asfef02d48c08d).What changed in this PR.
shader_disasm.require_exact_decodingsends 4 instructions in one cached llvm-mc call:161730f470d001fa(the scalar load, first)004010cc01ff011a003cfffb000008d501050202000003d7f0040202Each must come back as one instruction whose printed encoding equals its bytes. The output is matched to the checks by byte offset, so a misread one does not hide the others. The error names the scalar load first, as the cause of the junk
exp, then each other family that is wrong, what came out, and the release and LLVM commit that fix it. It refuses 21.1.8 and every 22.x, and accepts 23.1.0 and 23.1.6.Docs (with the table above), CI (
llvm-23),build_llvm_mc.ps1(23.1.6), the preflight messages and the 11 quickstarts now say 23.tests/fake_llvm_mc.pyreplays the outputs measured for 21.1.8, 22.1.2 and 23.1.6. A fake 22.1.2 is refused, with the scalar load named first.make_game.py's disassembly signature includes a fixed check revision. A work folder disassembled with an older llvm-mc is disassembled again, and a test pins this.Not covered.
v_dot4_i32_i8op_selwords. Separately,v_fma_mix*with a 32-bit literal prints only the low 16 bits in its encoding, in every version from 21.1.8 to 23.1.6.The original analysis below is superseded where it blames the
v_pk_*literal for theexpor says 22 is enough: on the real programs theexpcomes from the scalar loads above.Why
SHADER-804: with llvm-mc 21.1.8, five FidelityFX FSPX programs (05, 06, 08, 09, 28) fail to translate ("reachable instruction with normalized encoding", one
expin each); with llvm-mc 23 they translate, and rafaelpssz found that 23's listing has noexpat all.The
expis not an EXP encoding problem. Measured on a pod (gfx1010/gfx1030/gfx1013; llvm-mc 21.1.8, 22.1.8, 23.1.6; no game files):exp mrt0 off, ...in 21/22,exp mrt0, off, ...in 23). All three re-encode the reserved bits and the vsrc of disabled channels as 0. Nothing 21 prints asexpis a different opcode family, and the top-6-bit 0xFC.. words are invalid in all three. So (a) and (b) have nothing to handle.v_pk_mul_f16 v0, v1, 0xfbff3c00(bytes00 40 10 cc 01 ff 01 1a 00 3c ff fb) is aninvalid instruction encoding; it skips 4 bytes, reads the second word asv_dot4c_i32_i8and the literal asexp mrt0 off, off, off, off done compr vm. A literal whose top byte is 0xF8..0xFB does that, such as an f16 pair with -65504 (0xFBFF) in the high half. Same for v_pk_add_f16, v_pk_max_f16, v_pk_min_f16, v_pk_add_u16, v_pk_lshlrev_b16, v_pk_mul_lo_u16 ... 22.1.8 and 23.1.6 decode all of them, on gfx1010, gfx1013, gfx1030 and gfx1036.v_pk_*,v_fma_mix_f32,v_fma_mixhi_f16,v_fma_mixlo_f16); 22 matches 23 on all 71. For VOP3 the same count is 563 of 732 differ under 21 (22 matches 23 on all). Random words (150,000, gfx1030) also show 21 rejectingsrc_flat_scratch_base_lo/hioperands, which 22/23 accept.expcomma and in 23 accepting register tuples that run past s105 ([s104,s105,vcc_lo,vcc_hi]); 22 prints the stored 0 in unused VOP3 source fields like 21, 23 prints 0x80 (already handled, Translator: accept LLVM 23's 0x80 in unused VOP3 source fields; check for a .NET SDK #223).The rejected instruction is lost from the listing (the translator re-anchors only what LLVM printed), so no translator rule can recover it: the choice is (c), raise the documented minimum, and make the tool enforce it. Related: #4595 refuses a reachable fall-through into undecodable words; this PR keeps such listings from being produced in the first place. It does not conflict with #4697, #2038, #2323.
What
tools/shader_disasm.py:require_packed_literals(mcpu)disassemblesv_pk_mul_f16 v0, v1, 0xfbff3c00once per process (cached) and stops, naming the llvm-mc's LLVM version and the fix, when llvm-mc reports an invalid instruction or prints anexp. It runs insideprobe()(shader_disasm) and infspx_unpack.py --disasm, after its output-folder checks. An llvm-mc that fails for another reason is left to the existing per-shader reporting. The one extra llvm-mc run adds about 15 ms once.scripts/build_llvm_mc.ps1default-Version21.1.8 to 22.1.8 (tag llvmorg-22.1.8 exists; the script was not run, no Windows here). The conda route in README has no version pin (docs/testing.md already used 23.1.6)..github/workflows/ci.yml(translator-tests): installs llvm-22 from apt.llvm.org/noble (the 22 repo answers 200 for noble and jammy) and checksLLVM version 22..runtime.ymluses llvm-18 only to assemble GPU fixtures, which this does not touch.translator-testsjob (LLVM 22) now also runstests/test_shader_disasm.py::PackedLiteralTest, so the real-llvm-mc decode test runs there instead of being skipped.tests/test_shader_disasm.py(LLVM-21-like fake is refused with "LLVM 21.1.8" and "LLVM 22 or newer", no listing written; a real llvm-mc decodes the packed literal with 0 invalid words, skipped when no AMDGPU llvm-mc),tests/test_fspx_unpack.py(same refusal for--disasm, one fake adjusted so it only warns on shader input),tests/test_make_game_pipeline_preflight.py(message text).Tested with numbers
On a RunPod pod (Ubuntu 22.04, Python 3.13, no GPU needed), fresh copy of the tree each time:
test_llvm_21_is_refused_with_its_version_and_the_fix,test_llvm_21_losing_packed_literals_stops_before_any_listing), 53 passed. With this change: 92 passed, 3 skipped (shader_disasm, fspx_unpack, fspx_unpack_out, mc_command, fspx_shaders_stage); with 23.1.6: 55 passed, 1 skipped.shader_disasm.pyon a one-shader FSSM with the packed literal exits 1 with "'/usr/lib/llvm-21/bin/llvm-mc' is LLVM 21.1.8: it cannot decode a packed-math (VOP3P) instruction ... Use LLVM 22 or newer"; the real-llvm-mc test fails on 21 as intended; with 22.1.8 the same file givesv_pk_mul_f16 v0, v1, 0xfbff3c00, 0 invalid words.test_skip_assets_preflight_reduces_disk_space_requirement:posixpath.isjunction;test_parity_with_llvm_mc_on_shader_fixtures, exp null, TEST-1010: rdna2_decode: exp null is a special operand, as shader_ir parses it #4697), not touched here.Follow-up after review, RunPod pod, LLVM_MC = 22.1.8:
test_make_game_preflight80 passed (the two "LLVM 22+" message checks were red before),test_make_game_pipeline_preflight15,test_shader_disasm28,test_fspx_unpack27,test_ci_registration11,test_docs_links6 passed.pytest tests/test_shader_disasm.py::PackedLiteralTest(whattranslator-testsnow runs): 8 passed, the real decode test not skipped; with llvm-mc 21.1.8 the same command fails on the real decode test.Not covered
expsits right after aninvalid instruction encodingfor av_pk_*orv_fma_mix*word with a 0xFxxxxxxx literal.build_llvm_mc.ps1with 22.1.8 and the CI job on a GitHub runner were not run.Thanks to VeTkN for the report and rafaelpssz for the clue that 23.1.3 lists no
expat all.AI-assisted (Claude Code). No game files.