Fix post-merge CI regressions in wave_diff, x64_recomp, and piecewise_parse #2895

Merged
aslan2142 merged 1 commit from upstream-pr/2895 into main 2026-12-01 16:48:09 +00:00
aslan2142 commented 2026-12-01 15:55:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T15:55:10Z.


Summary

Fixes the CI regressions on main following the batch merge of approved PRs (#1329, #1428, #1809, #2237) plus a latent pushf/lahf EFLAGS materialization bug exposed by x64_recomp QEMU execution tests:

  1. tools/wave_diff.py (regression from #1809, broke tests/test_wave_diff.py and tests/test_wave_trace.py):
    • WaveRef._check_vgpr_dst(self, op, dst) shadowed cpu_ref.Machine._check_vgpr_dst(self, dst) (called with 1 arg by CpuRef._write_vgpr), causing TypeError: WaveRef._check_vgpr_dst() missing 1 required positional argument: 'dst'.
    • Renamed the WaveRef helper to _check_wave_vgpr_dst and updated its three internal call sites in WaveRef.step.
  2. tests/test_x64_recomp.py (regression from #1428):
    • #1428 fixed short-form xchg (0x90..0x97) to decode with Ov Av (32-bit default in 64-bit mode, 64-bit only with REX.W), making 41 90 (REX.B, no REX.W) decode as 32-bit xchg r8d, eax per the Intel SDM (verified with llvm-mc).
    • Updated DecodeTests.test_opcode_90_nop_pause_and_rex_xchg for 41 90 and added 49 90 (REX.W | REX.B -> 64-bit xchg r8, rax).
  3. tests/test_x64_recomp_adcsbb.py (regression from #1329, broke tests/test_x64_recomp_qemu_runner.py and QEMU runs):
    • Switched the QEMU fallback runner from xr.run_kernel (returns raw stdout bytes) to xr.run_result (returns parsed (int, tr)), matching every other test_x64_recomp_*.py suite.
  4. tools/x64_recomp.py (exposed by QEMU execution in tests/test_x64_recomp_incdec.py and tests/test_x64_recomp_adcsbb.py):
    • pushf and lahf unconditionally called self._mkflags(0), clobbering already-materialized CTX_EFLAGS (e.g. cmp; dec; jmp +0; pushf, neg; jmp +0; pushf, sbb; jmp +0; pushf) with un-inverted ARM C or stale NZCV.
    • Added _ensure_eflags(self, ins): skips _mkflags when CTX_EFLAGS is already materialized (prod is None, prod.mnem in ("popf", "sahf"), or prod.addr in self.mat), and otherwise passes the producer's kind (2 for LOGIC_KIND, 1 for SUB_KIND, 0 for ADD_KIND).
  5. tests/test_piecewise_parse.py (hash-seed flake from #2237):
    • code_facts() compared repr(frozenset) for co_consts, which depends on CPython hash-table order under randomized PYTHONHASHSEED.
    • Added _const_fact() to recursively canonicalize CodeType, frozenset, and tuple constants deterministically.

Testing

  • python3 -I scripts/check_no_game_data.py tools/wave_diff.py tools/x64_recomp.py tests/test_x64_recomp.py tests/test_x64_recomp_adcsbb.py tests/test_piecewise_parse.py — passed

  • python3 -m compileall -q make_game.py tools tests — passed

  • python3 -I make_game.py --help — passed

  • node --test tests/test_*.cjs — 110/110 passed

  • LEONIDA_REQUIRE_SPIRV_TOOLS=1 python3 -I scripts/run_semantic_tests.py tests/semantic — 557 files, 6780 tests, 0 failed

  • Full standalone Python suite (scripts/run_standalone_tests.py, 654 files, including QEMU aarch64 execution for test_x64_recomp_adcsbb.py and test_x64_recomp_incdec.py) — all 654 files passed (after fixing test_piecewise_parse.py and re-verifying across 8 PYTHONHASHSEED values + full 26-test suite)

  • pytest translator tests — 2069 passed, 15 skipped

  • GPUs tested: N/A (CPU-only Python/QEMU/JS tests on Linux x86_64)

  • AI-assisted: yes (Antigravity / Gemini; independently reviewed by a separate read-only reviewer agent)

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5589333531 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2895). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T15:55:10Z. --- ## Summary Fixes the CI regressions on `main` following the batch merge of approved PRs (`#1329`, `#1428`, `#1809`, `#2237`) plus a latent `pushf`/`lahf` EFLAGS materialization bug exposed by `x64_recomp` QEMU execution tests: 1. **`tools/wave_diff.py`** (regression from `#1809`, broke `tests/test_wave_diff.py` and `tests/test_wave_trace.py`): - `WaveRef._check_vgpr_dst(self, op, dst)` shadowed `cpu_ref.Machine._check_vgpr_dst(self, dst)` (called with 1 arg by `CpuRef._write_vgpr`), causing `TypeError: WaveRef._check_vgpr_dst() missing 1 required positional argument: 'dst'`. - Renamed the `WaveRef` helper to `_check_wave_vgpr_dst` and updated its three internal call sites in `WaveRef.step`. 2. **`tests/test_x64_recomp.py`** (regression from `#1428`): - `#1428` fixed short-form `xchg` (`0x90..0x97`) to decode with `Ov Av` (32-bit default in 64-bit mode, 64-bit only with `REX.W`), making `41 90` (`REX.B`, no `REX.W`) decode as 32-bit `xchg r8d, eax` per the Intel SDM (verified with `llvm-mc`). - Updated `DecodeTests.test_opcode_90_nop_pause_and_rex_xchg` for `41 90` and added `49 90` (`REX.W | REX.B` -> 64-bit `xchg r8, rax`). 3. **`tests/test_x64_recomp_adcsbb.py`** (regression from `#1329`, broke `tests/test_x64_recomp_qemu_runner.py` and QEMU runs): - Switched the QEMU fallback runner from `xr.run_kernel` (returns raw stdout bytes) to `xr.run_result` (returns parsed `(int, tr)`), matching every other `test_x64_recomp_*.py` suite. 4. **`tools/x64_recomp.py`** (exposed by QEMU execution in `tests/test_x64_recomp_incdec.py` and `tests/test_x64_recomp_adcsbb.py`): - `pushf` and `lahf` unconditionally called `self._mkflags(0)`, clobbering already-materialized `CTX_EFLAGS` (e.g. `cmp; dec; jmp +0; pushf`, `neg; jmp +0; pushf`, `sbb; jmp +0; pushf`) with un-inverted ARM `C` or stale NZCV. - Added `_ensure_eflags(self, ins)`: skips `_mkflags` when `CTX_EFLAGS` is already materialized (`prod is None`, `prod.mnem in ("popf", "sahf")`, or `prod.addr in self.mat`), and otherwise passes the producer's kind (`2` for `LOGIC_KIND`, `1` for `SUB_KIND`, `0` for `ADD_KIND`). 5. **`tests/test_piecewise_parse.py`** (hash-seed flake from `#2237`): - `code_facts()` compared `repr(frozenset)` for `co_consts`, which depends on CPython hash-table order under randomized `PYTHONHASHSEED`. - Added `_const_fact()` to recursively canonicalize `CodeType`, `frozenset`, and `tuple` constants deterministically. ## Testing - `python3 -I scripts/check_no_game_data.py tools/wave_diff.py tools/x64_recomp.py tests/test_x64_recomp.py tests/test_x64_recomp_adcsbb.py tests/test_piecewise_parse.py` — passed - `python3 -m compileall -q make_game.py tools tests` — passed - `python3 -I make_game.py --help` — passed - `node --test tests/test_*.cjs` — 110/110 passed - `LEONIDA_REQUIRE_SPIRV_TOOLS=1 python3 -I scripts/run_semantic_tests.py tests/semantic` — 557 files, 6780 tests, 0 failed - Full standalone Python suite (`scripts/run_standalone_tests.py`, 654 files, including QEMU aarch64 execution for `test_x64_recomp_adcsbb.py` and `test_x64_recomp_incdec.py`) — all 654 files passed (after fixing `test_piecewise_parse.py` and re-verifying across 8 `PYTHONHASHSEED` values + full 26-test suite) - `pytest` translator tests — 2069 passed, 15 skipped - **GPUs tested:** N/A (CPU-only Python/QEMU/JS tests on Linux x86_64) - **AI-assisted:** yes (Antigravity / Gemini; independently reviewed by a separate read-only reviewer agent)
merzleckeier commented 2026-12-01 16:09:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T16:09:50Z.


Post-merge CI reproduction with actual AArch64 execution at 9b7674d6 + 0ff8a532f, using Python 3.14 and QEMU 11.1.3. All 117 targeted test methods passed in seven files, including all 64 in the three x64 execution suites with the QEMU runner active. The same main baseline fails the wave tests, short-form XCHG expectation, QEMU fallback check and INC/DEC/NEG flag cases. The targeted piecewise code-object comparison passed for seeds 0, 1, 4 and 17 on the PR. Main failed at 4 and 17.

One existing gap in the LAHF part of the description: a minimal synthetic integer comparison followed by LAHF is decoded but recorded as unhandled by the emitter on both main and this PR. Under QEMU it never reaches the result. The matched control without LAHF returns normally. The new LAHF flag-materialization call sits in _emit_alu, but the dispatcher does not route this mnemonic there.

I tried routing LAHF to that existing handler and setting the fixed bit 1 in the byte it returns. Borrow, equal and greater comparisons then matched native x64 in all six cases (each comparison both in the same block and across a jump). This was a local trial. The suite result above is for the unmodified PR head.

MEASURED with synthetic code. AI-assisted (Codex).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7317140249 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2895#issuecomment-7317140249). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T16:09:50Z. --- Post-merge CI reproduction with actual AArch64 execution at 9b7674d6 + 0ff8a532f, using Python 3.14 and QEMU 11.1.3. All 117 targeted test methods passed in seven files, including all 64 in the three x64 execution suites with the QEMU runner active. The same main baseline fails the wave tests, short-form XCHG expectation, QEMU fallback check and INC/DEC/NEG flag cases. The targeted piecewise code-object comparison passed for seeds 0, 1, 4 and 17 on the PR. Main failed at 4 and 17. One existing gap in the LAHF part of the description: a minimal synthetic integer comparison followed by LAHF is decoded but recorded as unhandled by the emitter on both main and this PR. Under QEMU it never reaches the result. The matched control without LAHF returns normally. The new LAHF flag-materialization call sits in _emit_alu, but the dispatcher does not route this mnemonic there. I tried routing LAHF to that existing handler and setting the fixed bit 1 in the byte it returns. Borrow, equal and greater comparisons then matched native x64 in all six cases (each comparison both in the same block and across a jump). This was a local trial. The suite result above is for the unmodified PR head. MEASURED with synthetic code. AI-assisted (Codex).
MoonEyes commented 2026-12-01 16:12:56 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-01T16:12:56Z.


Checked head 9b7674d64 merged into main 0ff8a532f (clean merge), Windows 11, Python 3.14.0.

test file main main + this PR
test_wave_diff fails (_check_vgpr_dst() missing 1 required positional argument) 16 OK
test_wave_trace 4 errors, same cause 10 OK
test_x64_recomp 1 failure (41 90) OK (34 skipped)
test_x64_recomp_qemu_runner 1 failure (adcsbb calls run_kernel) OK
every test_x64_recomp_*.py exit 0 (execution tests skipped)

test_piecewise_parse on this machine: 4 failures without this PR, 1 with it: WarningsTest.test_the_compiler_warns_once_too. That one fails without the PR too, so it is not new. It passes in CI; I have not looked for the cause (perhaps my Python 3.14).

Not checked: the pushf/lahf change. There is no QEMU here, so the tests that run the translated code are skipped. The 41 90 / 49 90 expectations match REX.B without and with REX.W.

Red and green for the four files that make main's CI red. Not a full review of the x64_recomp.py part.

AI-assisted (Claude).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7317226893 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2895#issuecomment-7317226893). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-01T16:12:56Z. --- Checked head `9b7674d64` merged into main `0ff8a532f` (clean merge), Windows 11, Python 3.14.0. | test file | main | main + this PR | | --- | --- | --- | | test_wave_diff | fails (`_check_vgpr_dst() missing 1 required positional argument`) | 16 OK | | test_wave_trace | 4 errors, same cause | 10 OK | | test_x64_recomp | 1 failure (`41 90`) | OK (34 skipped) | | test_x64_recomp_qemu_runner | 1 failure (adcsbb calls `run_kernel`) | OK | | every `test_x64_recomp_*.py` | | exit 0 (execution tests skipped) | `test_piecewise_parse` on this machine: 4 failures without this PR, 1 with it: `WarningsTest.test_the_compiler_warns_once_too`. That one fails without the PR too, so it is not new. It passes in CI; I have not looked for the cause (perhaps my Python 3.14). Not checked: the `pushf`/`lahf` change. There is no QEMU here, so the tests that run the translated code are skipped. The 41 90 / 49 90 expectations match REX.B without and with REX.W. Red and green for the four files that make main's CI red. Not a full review of the `x64_recomp.py` part. AI-assisted (Claude).
Neutron-0 commented 2026-12-01 16:53:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Neutron-0 on 2026-12-01T16:53:46Z.


Verified on Windows 11, Python 3.13.5, no GPU and no game files.

The pull request's central fix is red on main and green on the head. tests/test_wave_diff.py and tests/test_wave_trace.py fail on the base 0ff8a532f with exactly the error the description names:

TypeError: WaveRef._check_vgpr_dst() missing 1 required positional argument: 'dst'
Ran 16 tests ... FAILED (failures=1, errors=35)      # test_wave_diff.py
Ran 10 tests ... FAILED (errors=4)                   # test_wave_trace.py

On the head 9b7674d64 both are green: Ran 16 tests ... OK and Ran 10 tests ... OK. The shadowing of cpu_ref.Machine._check_vgpr_dst(self, dst) by WaveRef._check_vgpr_dst(self, op, dst) is the cause, and the rename to _check_wave_vgpr_dst is the fix. The pull request does not touch these two test files, and it does not have to: the existing tests already fail on main and pass with the change. That is the proof the repository's own rule asks for.

This is also why main's CI is red. The CI run on main at 0ff8a532f fails in the "Tests (standard library only)" step with:

##[error]tests/test_wave_diff.py failed
##[error]tests/test_wave_trace.py failed
##[error]tests/test_x64_recomp.py failed
##[error]tests/test_x64_recomp_qemu_runner.py failed
##[error]654 files, 4 files failed

These are the same four files this pull request repairs (its tests/test_x64_recomp.py edit is the 41 90 / 49 90 case, and tests/test_x64_recomp_qemu_runner.py is what tests/test_x64_recomp_adcsbb.py switches the QEMU fallback runner to match). A pull request that lands the four repairs unblocks main's CI.

The other two changes, measured.

  • tests/test_piecewise_parse.py: the co_consts comparison now goes through _const_fact(), which canonicalises CodeType, frozenset and tuple constants, so the hash-seed flake is gone. The file's 26 tests pass on the head under python -I (the runner the repository documents). Note that under pytest one test in this file fails on the head and on main with AssertionError: <class '_frozen_importlib_external.SourceFileLoader'> is not <class 'support.PiecewiseLoader'>: that is an artifact of this machine's Anaconda Python 3.13.5 under pytest's import order, not of the change - python -I tests/test_piecewise_parse.py passes all 26.
  • tools/x64_recomp.py's pushf/lahf fix (_ensure_eflags): this one needs QEMU for aarch64 execution to observe, and there is no QEMU on this machine, so the pushf/lahf half is not verified here. tests/test_x64_recomp_adcsbb.py reports OK (skipped=3) and tests/test_x64_recomp.py OK (skipped=34) on the head, so the QEMU-gated tests did not run.

One note on the claim. The description says the pull request "fixes the CI regressions on main". On the head, tests/test_x64_recomp.py and tests/test_x64_recomp_qemu_runner.py are repaired by the edits to tests/test_x64_recomp.py and tests/test_x64_recomp_adcsbb.py alone - the source they test (tools/x64_recomp.py) is not changed for the xchg case, because #1428 already fixed the decoder and the test was the part left behind. That is correct as it stands, but it means the xchg part of the pull request is a test repair, not a source fix, and the summary lists it next to two source fixes. Worth a line in the description so a reviewer knows the xchg item needs no source change.

Not checked: the QEMU execution paths (no QEMU here); a real shader translation (no game files).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7318414679 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2895#issuecomment-7318414679). Originally posted by [Neutron-0](https://github.com/Neutron-0) on 2026-12-01T16:53:46Z. --- Verified on Windows 11, Python 3.13.5, no GPU and no game files. **The pull request's central fix is red on `main` and green on the head.** `tests/test_wave_diff.py` and `tests/test_wave_trace.py` fail on the base `0ff8a532f` with exactly the error the description names: ``` TypeError: WaveRef._check_vgpr_dst() missing 1 required positional argument: 'dst' Ran 16 tests ... FAILED (failures=1, errors=35) # test_wave_diff.py Ran 10 tests ... FAILED (errors=4) # test_wave_trace.py ``` On the head `9b7674d64` both are green: `Ran 16 tests ... OK` and `Ran 10 tests ... OK`. The shadowing of `cpu_ref.Machine._check_vgpr_dst(self, dst)` by `WaveRef._check_vgpr_dst(self, op, dst)` is the cause, and the rename to `_check_wave_vgpr_dst` is the fix. **The pull request does not touch these two test files, and it does not have to: the existing tests already fail on `main` and pass with the change.** That is the proof the repository's own rule asks for. **This is also why `main`'s CI is red.** The `CI` run on `main` at `0ff8a532f` fails in the "Tests (standard library only)" step with: ``` ##[error]tests/test_wave_diff.py failed ##[error]tests/test_wave_trace.py failed ##[error]tests/test_x64_recomp.py failed ##[error]tests/test_x64_recomp_qemu_runner.py failed ##[error]654 files, 4 files failed ``` These are the same four files this pull request repairs (its `tests/test_x64_recomp.py` edit is the `41 90` / `49 90` case, and `tests/test_x64_recomp_qemu_runner.py` is what `tests/test_x64_recomp_adcsbb.py` switches the QEMU fallback runner to match). A pull request that lands the four repairs unblocks `main`'s CI. **The other two changes, measured.** - `tests/test_piecewise_parse.py`: the `co_consts` comparison now goes through `_const_fact()`, which canonicalises `CodeType`, `frozenset` and `tuple` constants, so the hash-seed flake is gone. The file's 26 tests pass on the head under `python -I` (the runner the repository documents). Note that under `pytest` one test in this file fails on the head **and on `main`** with `AssertionError: <class '_frozen_importlib_external.SourceFileLoader'> is not <class 'support.PiecewiseLoader'>`: that is an artifact of this machine's Anaconda Python 3.13.5 under pytest's import order, not of the change - `python -I tests/test_piecewise_parse.py` passes all 26. - `tools/x64_recomp.py`'s `pushf`/`lahf` fix (`_ensure_eflags`): this one needs QEMU for aarch64 execution to observe, and there is no QEMU on this machine, so the `pushf`/`lahf` half is **not verified here**. `tests/test_x64_recomp_adcsbb.py` reports `OK (skipped=3)` and `tests/test_x64_recomp.py` `OK (skipped=34)` on the head, so the QEMU-gated tests did not run. **One note on the claim.** The description says the pull request "fixes the CI regressions on `main`". On the head, `tests/test_x64_recomp.py` and `tests/test_x64_recomp_qemu_runner.py` are repaired by the edits to `tests/test_x64_recomp.py` and `tests/test_x64_recomp_adcsbb.py` alone - the *source* they test (`tools/x64_recomp.py`) is not changed for the `xchg` case, because #1428 already fixed the decoder and the test was the part left behind. That is correct as it stands, but it means the `xchg` part of the pull request is a **test repair**, not a source fix, and the summary lists it next to two source fixes. Worth a line in the description so a reviewer knows the `xchg` item needs no source change. **Not checked:** the QEMU execution paths (no QEMU here); a real shader translation (no game files).
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!2895
No description provided.