translator: a listing the translator cannot read is refused, not fatal #3077
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3077"
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?
Imported from ubiquitarianism/leonida. Originally posted by imShangLi on 2026-12-02T09:32:34Z.
Claimed in the coordination issue as: TRANSLATOR-UNREADABLE-LISTING (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7339518154)
What and why
A listing is data: llvm-mc's text for what it decoded. What the translator does not model is reported (
Unsupported, by name), never guessed — the contract indocs/design.md. Two shapes of text it cannot read ended the translation with a Python traceback instead of that report:tools/shader_ir.pyleaves an operand it cannot parse as{"k": "raw"}and its own comment says such an operand isUnsupported. The translator honoured that on the paths that read an operand throughsrc_u(a source) anddst(a destination), but not on the paths that read the operand dict directly — an address, a data register — where it failed withKeyError: 'r'. The check is now at the dispatch boundary (Gen.insn), so every position refuses the same way, naming the instruction and the operand.op_sel:[...],op_sel_hi:[...]andneg_lo:[...]were read withint()in fourteen places, each of which failed withValueErroron a value that is not a number. They are read in one place now (_modifier_bits;modifier_bitsturns it into the refusal, and the two analyses that only look at a modifier answer conservatively through it), which refuses the modifier by name.A
swizzle(...)modifier whose arguments are not numbers does not match the pattern the translator reads it with, so it is refused as such (ds_swizzle pattern), like any other listing the translator cannot read.Tested
python3 -I scripts/red_green.py fix/translator-refuse-unreadable-listing --remote fork --base origin/main --no-cargo— verdict red then green: the red side (the merge base0ae5a266plus only the new test file) fails all four new tests, the green side (the head) passes them, 0 regressions.python3 -I -m unittest discover -s tests/semantic -p 'test_translator_unreadable.py'— withtools/rdna2spirv.pyback tomainand the new test kept: 3 failures and 1 error (the address case ends inKeyError: 'r', the modifier case inValueError); with the change: 4 tests, all pass.tests/semantic/test_translator_unreadable.py): an unreadable operand in the destination, a source and an address position; an unreadable modifier value; a modifier that is not one; and a seeded sweep that replaces one operand of one instruction of every fixture intests/semantic/fixtures/disasm/(112 listings) by text the parser cannot read and requires each one to be refused. 0.5 s.python3 -I scripts/run_semantic_tests.py tests/semantic— 560 files, 6,791 tests, 0 failed on the branch (the same onmain).python3 -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_translator_unreadable.py docs/design.md— clean.Two shapes are not refused by this change, and are reported as findings instead (with the sites and the evidence): an instruction with fewer operands than its op reads (an
IndexErroror aValueError), and an operand that is not a register where the op reads one (aKeyError, and an SGPR read as a VGPR of the same number — a wrong address, silently). The first needs the op's operand count (theIndexErrorcarries no index); the second followsGen.addr_regs, which refuses this for an image address already.GPUs tested: n/a (no GPU test; the translator's suite is CPU-only)
AI-assisted: yes — MiniMax M3.1 Flash wrote the change; SenseNova 6.8 Flash Lite reviewed it read-only.
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T14:23:12Z.
RUN (independent run on Windows, #3077 head
cb7aa587, merged locally intomainf6dd2242withgit merge --no-ff, merge commit 6e758d09; the machine was busy with other runs)Red (the new test file against
tools/rdna2spirv.pyas onmain, the rest of the merge unchanged):python -I -m unittest discover -s tests/semantic -p test_translator_unreadable.py-> 4 tests, all 4 fail (2 failures, 2 errors):ValueError: invalid literal for int() ... 'v3x'(modifier),KeyError: 'r'(the sweep over the 112 fixtures), and two assertions that "operand not understood" is not in the message. File swapped back afterwards,git statusclean.Green (merge): the same command -> 4 tests, OK.
python -I scripts/run_semantic_tests.py tests/semantic-> 560 files, 6791 tests, 0 files failed (1844 s, 12 jobs, machine under load).check_no_game_data.pyon the three changed files: clean.Mutations of
tools/rdna2spirv.py(6), run againsttest_translator_unreadable.py:Gen.insndisabled: killed (2 failures, 1 error)_modifier_bitscatching onlyIndexError: killedmodifier_bitsreturning[0,0,0]instead of raisingUnsupported: SURVIVED_modifier_bitswithout the closing-]check: SURVIVED (theint()failure still refuses such text)Not covered: the two surviving mutations (the new test never reaches the
modifier_bitsraise through a path whose refusal depends on it, and the]check). The two shapes the PR reports as findings (fewer operands than the op reads, a non-register operand) are not refused by this change. No GPU test; no unrefused-listing corpus run (needs game files).Merge conditions: CI on head
cb7aa587all green (change-scope, check, linux-python-and-viewer, no-game-data, semantic-tests); no review and no comment on the PR; claimed in #2570 (TRANSLATOR-UNREADABLE-LISTING, comment 7339518154); the author has 13 merged PRs; noDepends on.Verdict: PASS (red and green shown, no blocker; two mutations survive, a gap in the test and not in the change)
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T14:23:51Z.
Merging. Head
cb7aa587bmerges cleanly withmain69cd4106cand does not force a rebase of #2566. Independent red/green by MoonEyes' agent on headcb7aa587bb(red: 4 of 4 new tests fail on main; green: 4 tests OK and 560 files / 6791 tests pass; 6 mutations, 4 killed and 2 survive as a test gap), see https://github.com/ProjectLeonida/mandy/pull/3077#issuecomment-7348457186; CI green including no-game-data, no open review or question, item TRANSLATOR-UNREADABLE-LISTING claimed in #2570. Merged by MoonEyes.AI-assisted (Claude Code).