tooling: add call chains, skipped calls and unexported callees to the CPU fuzz test #1122

Merged
tedin7 merged 4 commits from upstream-pr/1129 into main 2026-11-24 03:34:29 +00:00
tedin7 commented 2026-11-24 01:34:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T01:34:57Z.


Change

Follow-up to #1164 (Refs #446). Rebased onto the merged baseline; only what cpu_aot_fuzz_calls does not cover is kept, as a separate --area chains in tools/fuzz_cpu.py. It reuses the baseline's Function, NONVOLATILE and part helpers, its check and report path and its per-area mutant table.

  • A pool of 7 callees that no export names (leaf mixes, a branch, an AL-only return, a store through R8, a 32-bit result, two framed callees that call lower ones), so chains nest two levels deep.
  • 16 exports: call chains of 2 to 4 calls, calls skipped behind a TEST and JZ, and tail jumps (plain, after POP, two arms) including to framed callees.
  • cpu_aot_fuzz_chains in CMakeLists.txt: native, default-translated and /O2-translated exports, 10,016 comparisons at seed 0xCA11.
  • Distinct negative control: --mutant passes RDX before RCX at every direct call and tail jump (the baseline plants a retargeted call). The test fails unless that build differs from native.
  • docs/experiments.md: one new paragraph; one sentence in the baseline paragraph points to it.

AI-assisted. Fixtures are generated from the seed; nothing is copied from elsewhere.

Verification

  • Not run: ctest --preset dev -R '^cpu_aot_fuzz_chains$' on Windows with MSVC (no Windows machine). CI is the first MSVC run.
  • Linux: llvm-ml-19, lld-link-19, MinGW g++ (-O0 and -O2) and Wine against the native DLL, on this merge commit: chains total=5008 bad=0 for each build; mutant bad=3711 of 5008 in 13 of 16 functions. The baseline calls area at the same commit is unchanged: bad=0, mutant 313 of 7825.
  • Negative control on origin/main: python3 -B tools/fuzz_cpu.py emit 0xCA11 16 a b --area chains fails with invalid choice: 'chains'; with this change it succeeds.
  • python3 -B tests/docs_links_check.py: 15 files, 263 links. docs/experiments.md grows by 2 lines (one paragraph).

Evidence and follow-up

Assumption: MinGW and Wine exercise the same translated C++, not MSVC code generation. Recursion, indirect calls, dead reads, fault equivalence and RBP frames remain follow-ups.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6572591615 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1129). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T01:34:57Z. --- ## Change Follow-up to #1164 (Refs #446). Rebased onto the merged baseline; only what `cpu_aot_fuzz_calls` does not cover is kept, as a separate `--area chains` in `tools/fuzz_cpu.py`. It reuses the baseline's `Function`, `NONVOLATILE` and `part` helpers, its check and report path and its per-area mutant table. - A pool of 7 callees that no export names (leaf mixes, a branch, an AL-only return, a store through R8, a 32-bit result, two framed callees that call lower ones), so chains nest two levels deep. - 16 exports: call chains of 2 to 4 calls, calls skipped behind a TEST and JZ, and tail jumps (plain, after `POP`, two arms) including to framed callees. - `cpu_aot_fuzz_chains` in `CMakeLists.txt`: native, default-translated and `/O2`-translated exports, 10,016 comparisons at seed `0xCA11`. - Distinct negative control: `--mutant` passes RDX before RCX at every direct call and tail jump (the baseline plants a retargeted call). The test fails unless that build differs from native. - `docs/experiments.md`: one new paragraph; one sentence in the baseline paragraph points to it. AI-assisted. Fixtures are generated from the seed; nothing is copied from elsewhere. ## Verification - Not run: `ctest --preset dev -R '^cpu_aot_fuzz_chains$'` on Windows with MSVC (no Windows machine). CI is the first MSVC run. - Linux: `llvm-ml-19`, `lld-link-19`, MinGW g++ (-O0 and -O2) and Wine against the native DLL, on this merge commit: chains total=5008 bad=0 for each build; mutant bad=3711 of 5008 in 13 of 16 functions. The baseline `calls` area at the same commit is unchanged: bad=0, mutant 313 of 7825. - Negative control on origin/main: `python3 -B tools/fuzz_cpu.py emit 0xCA11 16 a b --area chains` fails with `invalid choice: 'chains'`; with this change it succeeds. - `python3 -B tests/docs_links_check.py`: 15 files, 263 links. `docs/experiments.md` grows by 2 lines (one paragraph). ## Evidence and follow-up Assumption: MinGW and Wine exercise the same translated C++, not MSVC code generation. Recursion, indirect calls, dead reads, fault equivalence and RBP frames remain follow-ups. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets.
upstream-sync closed this pull request 2026-11-24 06:46:29 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:46:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T02:15:22Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f8407ade24

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6032630118 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1129#pullrequestreview-6032630118). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T02:15:22Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `f8407ade24` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
chatgpt-codex-connector[bot commented 2026-11-24 06:50:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T02:15:26Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T02:15:24.682755Z f8407ad Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7119928964 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1129#issuecomment-7119928964). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T02:15:26Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"f8407ade24da7f91b34a0a58982a7b3524980476","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T02:15:24.682755Z">2026-11-24T02:15:24.682755Z</relative-time> | `f8407ad` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
tedin7 commented 2026-11-24 06:50:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T02:17:53Z.


Fixed the bot finding: the cpu_aot_fuzz_calls paragraph in docs/experiments.md had lost the $ of its regex to shell expansion, which also pulled in a duplicated copy of the document tail. The file is restored from the base with only the three intended paragraphs changed (4 insertions, 2 changes against base), the command reads ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_calls$' -V, and origin/main is merged in (no force). Code and CMake were not touched by this fix. AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7119984167 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1129#issuecomment-7119984167). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T02:17:53Z. --- Fixed the bot finding: the `cpu_aot_fuzz_calls` paragraph in `docs/experiments.md` had lost the `$` of its regex to shell expansion, which also pulled in a duplicated copy of the document tail. The file is restored from the base with only the three intended paragraphs changed (4 insertions, 2 changes against base), the command reads `ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_calls$' -V`, and origin/main is merged in (no force). Code and CMake were not touched by this fix. AI-assisted.
R0Y00 commented 2026-11-24 06:50:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T02:23:53Z.


Thanks for restoring the docs and keeping the work distinct. We are reviewing the direct-call baseline in #1164 first. The native/default-/O2 comparison and its wrong-callee control passed locally. Once the baseline lands, your deeper call chains, skipped conditional calls and unexported callees would be useful as a focused follow-up. Please keep those cases and any distinct control that catches something the baseline misses.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7120098337 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1129#issuecomment-7120098337). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T02:23:53Z. --- Thanks for restoring the docs and keeping the work distinct. We are reviewing the direct-call baseline in #1164 first. The native/default-/O2 comparison and its wrong-callee control passed locally. Once the baseline lands, your deeper call chains, skipped conditional calls and unexported callees would be useful as a focused follow-up. Please keep those cases and any distinct control that catches something the baseline misses.
tedin7 commented 2026-11-24 06:50:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T02:45:47Z.


Thanks, that sounds right. Once #1164 is on main I will rebase this branch as a focused follow-up: deeper call chains, skipped conditional calls, unexported callees, and any control that catches something the direct-call baseline misses. I will drop whatever #1164 already covers so the diff stays small.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7120455593 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1129#issuecomment-7120455593). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T02:45:47Z. --- Thanks, that sounds right. Once #1164 is on main I will rebase this branch as a focused follow-up: deeper call chains, skipped conditional calls, unexported callees, and any control that catches something the direct-call baseline misses. I will drop whatever #1164 already covers so the diff stays small. AI-assisted.
tedin7 commented 2026-11-24 06:50:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T02:53:22Z.


AI-assisted. Rebased onto the merged #1164 (merge commit, no force push). What is left is only what the baseline does not cover: callees that no export names, call chains up to four calls long that nest two levels deep, calls skipped behind a conditional, and tail jumps to framed callees, as a separate --area chains / cpu_aot_fuzz_chains. The distinct control is swapped call arguments, not a retargeted call. The baseline's own generators, clobber callee and controls are not duplicated; the new code reuses its helpers. Local Linux run (Wine): clean 0 of 5008 mismatches, mutant 3711 of 5008, baseline calls unchanged. Waiting for the 4 CI jobs.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7120573113 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1129#issuecomment-7120573113). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T02:53:22Z. --- AI-assisted. Rebased onto the merged #1164 (merge commit, no force push). What is left is only what the baseline does not cover: callees that no export names, call chains up to four calls long that nest two levels deep, calls skipped behind a conditional, and tail jumps to framed callees, as a separate `--area chains` / `cpu_aot_fuzz_chains`. The distinct control is swapped call arguments, not a retargeted call. The baseline's own generators, clobber callee and controls are not duplicated; the new code reuses its helpers. Local Linux run (Wine): clean 0 of 5008 mismatches, mutant 3711 of 5008, baseline `calls` unchanged. Waiting for the 4 CI jobs.
chatgpt-codex-connector[bot commented 2026-11-24 06:50:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T02:15:22Z.

Code review location: docs/experiments.md; line 2102

@@ -2095,9 +2095,4935 @@ Two independently located local effects yielded 5 and 81 candidates across all g
 
 [#446](https://github.com/R0Y00/Xbox2Windows/issues/446) asks for native and translated functions to run side by side on generated inputs. `tools/fuzz_cpu.py` generates deterministic leaf functions for the shared `cpu_switch_aot` lifter. The default smoke generates 20 functions from seed `0xA902`: 8-, 16-, 32- and 64-bit ALU chains, shifts and rotates, CMP and TEST producers feeding SETcc, CMOVcc and Jcc consumers, a forward branch diamond, and a Jcc to its own fallthrough. Each function starts from RCX and RDX and writes to the R8 output buffer. The build writes one MASM DLL, translates all 20 exports into one C++ source, and builds that source at the preset's optimization and again at `/O2`. The test calls the native, default-translated and `/O2`-translated exports with 313 deterministic input pairs per function and compares RAX plus a guarded 256-byte output buffer. It performs 12,520 comparisons in about 0.35 s on Windows 11 build 26200 with MSVC 19.52.
 
-Run `ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_smoke$' -V`. `CPU_FUZZ_FUNCTIONS` and `CPU_FUZZ_SEED` select a longer manual run; 96 functions at seed `0xCCD1` made 60,096 comparisons in about 1.1 s. A mismatch prints the seed, function, input and one-function MASM; `--only NAME --input INDEX` repeats that case. The leaf scope is ALU, flags and branches; calls, shared callees, tail jumps, dead reads and fault equivalence remain follow-ups. A case worth keeping can be reduced to a fixed fixture with the existing `cpu_asm_fixture` and `cpu_translation` helpers.
+Run `ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_smoke$' -V`. `CPU_FUZZ_FUNCTIONS` and `CPU_FUZZ_SEED` select a longer manual run; 96 functions at seed `0xCCD1` made 60,096 comparisons in about 1.1 s. A mismatch prints the seed, function, input and one-function MASM; `--only NAME --input INDEX` repeats that case. The leaf scope is ALU, flags and branches; dead reads and fault equivalence remain follow-ups, and calls, shared callees and tail jumps are in `cpu_aot_fuzz_calls` below. A case worth keeping can be reduced to a fixed fixture with the existing `cpu_asm_fixture` and `cpu_translation` helpers.
+
+`cpu_aot_fuzz_frames` runs the same comparison on generated functions with fixed RSP frames (`--area frames`), from its own seed, so the leaf smoke above is unchanged. Each function saves one to three of RBX, RSI, RDI and R12 to R15 with `PUSH`, or saves RBX and RSI into home space with `MOV` before `PUSH RDI`, as MSVC does at `/O2`. It then allocates 16 to 40 bytes with `SUB RSP` and keeps RSP 16-byte aligned. The prologue carries the matching `.pushreg`, `.savereg` and `.allocstack` directives. Each saved register is overwritten from RCX and RDX before it is used, because the translator rejects any read of a nonvolatile register's entry value. A 16-byte region of the allocation is filled by a random sequence of 8-, 4-, 2- and 1-byte stores from registers or immediates. Some functions then add a register to a piece of the region in place, or overwrite one or two bytes on either side of a branch. Four to six reloads read 1, 2, 4 or 8 bytes at an offset within the region, zero- or sign-extended. The first is placed across a boundary between two stores. Every reloaded value goes to the output buffer and into RAX. The function restores the saved registers with `MOV` or `POP` and releases the frame with `ADD RSP`. The default run uses seed `0xF4A3` and 16 functions: 5 home-space saves, 90 stores into the regions and 82 reloads, of which 19 are 8-byte, 23 are 4-byte, 24 are 2-byte and 16 are 1-byte. Of the reloads, 44 span two or more stores (at least one in each function), 33 read part of one store and 5 read one store exactly. Nine functions have a branch and 9 have an in-place add. It makes 10,016 native, default and `/O2` comparisons in about 0.3 s. A planted translator fault must be detected: `--mutant` translates the same exports with every frame reload narrower than 8 bytes moved one byte higher in the frame array. The test fails unless that build differs from native. At the default seed, 4,945 of 5,008 calls differed, in all 16 functions. Passing the clean translation as `--mutant` fails with `the planted translator fault was not detected`, and passing the mutant as the translation fails at the first mismatch with the reproduction command. A dropped register restore would not serve as the planted fault, because the generated locals are not the physical registers (see `cpu_aot_stack_frames`). `CPU_FUZZ_FRAMES_SEED` and `CPU_FUZZ_FRAMES_FUNCTIONS` select a longer run. Seeds `0x1`, `0x2`, `0xBEEF` and `0xCCD1` at 128 functions each made 80,128 comparisons per seed in about 1.2 s, with no refusal and no mismatch; 1,450 of their 2,578 reloads span two or more stores. The generator does not use an RBP frame pointer, `LEAVE` or a mid-body RSP change; calls are covered by `cpu_aot_fuzz_calls` below. Run `ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_frames$' -V`.
+
+`cpu_aot_fuzz_calls` runs the same comparison on generated chains of direct calls, callees shared between callers and tail jumps (`--area calls`), from its own seed, so the smokes above are unchanged. The generator first builds a pool of seven callees that no export names. Each has its own unwind entry, and callee *i* only calls a callee below it, so the pool has no cycles. Three are frameless leaves (an LEA, ADD, XOR and ROL mix; a CMP and JB branch that returns the absolute difference; a 32-bit LEA and ROL that writes EAX), one returns only AL, one stores its result into its own word of the output buffer through R8, and two have a frame that calls one or two lower callees and combines the results, one holding RDX in a pushed register and one in a spill slot above the callee's home space. The sixteen exported functions cycle through six shapes. Eight are call chains of two to four calls from a frame that keeps the output pointer, x and y in pushed registers or a spill slot, reloads RCX, RDX and R8 before each call, widens a byte-sized return with MOVZX and feeds each result into the next call's arguments. Five of those shapes may skip a call behind a TEST and JZ on the saved x, and three functions do. Eight are tail jumps (three, three and two of the forms below): ADD and XOR on the arguments and then a JMP to a callee, the same after `MOV`, a store through R8 and `POP RBX`, or two JMPs to different callees in the two arms of a TEST and JNZ. A callee that returns only AL is never a tail target, because the caller's RAX would keep undefined upper bytes. The default run uses seed `0xCA11` and 16 functions: 7 callees, 23 call sites (20 in the exports and 3 in the callees) and 10 tail jumps, reaching every callee between 2 and 7 times in total, and the callees nest two deep. It makes 10,016 native, default and `/O2` comparisons of RAX and the 256-byte output buffer. A planted translator fault must be detected: `--mutant` translates the same exports and then passes RDX before RCX at every direct call and tail jump in the emitted C++. The test fails unless that build differs from native, and fails with `the planted translator fault was not detected` when the clean translation is passed as `--mutant`. Without MSVC, the same seed was run on Linux with `llvm-ml-19`, `lld-link-19`, a MinGW build of the translation (at `-O0` and `-O2`) and a small loader under Wine: 5,008 native against translated comparisons per build with no mismatch, and the planted fault differed in 3,711 of 5,008 calls, in 13 of the 16 functions. The `ctest` run on Windows with MSVC is not yet recorded here. Run `ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_calls `CPU_FUZZ_CALLS_SEED` and `CPU_FUZZ_CALLS_FUNCTIONS` select a longer run. Dead reads, fault equivalence and RBP frame pointers remain follow-ups.

P2 Badge Restore the calls command without duplicating the document tail

Following the new reproduction instructions leaves the shell with an unterminated quote: the command stops at -R '^cpu_aot_fuzz_calls rather than providing the complete regex argument (ctest --help documents -R <regex> as “Run tests matching regular expression”). The -V fragment appears at line 7025, after an accidental 4,920-line copy of the remaining experiment notes, which then repeat starting at line 7028. Remove the extra copy and restore ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_calls$' -V so contributors can reproduce the new experiment without navigating duplicated documentation.

AGENTS.md reference: AGENTS.md:L153-L156

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4674655394 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1129#discussion_r4674655394). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T02:15:22Z. **Code review location:** `docs/experiments.md`; line 2102 ~~~~diff @@ -2095,9 +2095,4935 @@ Two independently located local effects yielded 5 and 81 candidates across all g [#446](https://github.com/R0Y00/Xbox2Windows/issues/446) asks for native and translated functions to run side by side on generated inputs. `tools/fuzz_cpu.py` generates deterministic leaf functions for the shared `cpu_switch_aot` lifter. The default smoke generates 20 functions from seed `0xA902`: 8-, 16-, 32- and 64-bit ALU chains, shifts and rotates, CMP and TEST producers feeding SETcc, CMOVcc and Jcc consumers, a forward branch diamond, and a Jcc to its own fallthrough. Each function starts from RCX and RDX and writes to the R8 output buffer. The build writes one MASM DLL, translates all 20 exports into one C++ source, and builds that source at the preset's optimization and again at `/O2`. The test calls the native, default-translated and `/O2`-translated exports with 313 deterministic input pairs per function and compares RAX plus a guarded 256-byte output buffer. It performs 12,520 comparisons in about 0.35 s on Windows 11 build 26200 with MSVC 19.52. -Run `ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_smoke$' -V`. `CPU_FUZZ_FUNCTIONS` and `CPU_FUZZ_SEED` select a longer manual run; 96 functions at seed `0xCCD1` made 60,096 comparisons in about 1.1 s. A mismatch prints the seed, function, input and one-function MASM; `--only NAME --input INDEX` repeats that case. The leaf scope is ALU, flags and branches; calls, shared callees, tail jumps, dead reads and fault equivalence remain follow-ups. A case worth keeping can be reduced to a fixed fixture with the existing `cpu_asm_fixture` and `cpu_translation` helpers. +Run `ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_smoke$' -V`. `CPU_FUZZ_FUNCTIONS` and `CPU_FUZZ_SEED` select a longer manual run; 96 functions at seed `0xCCD1` made 60,096 comparisons in about 1.1 s. A mismatch prints the seed, function, input and one-function MASM; `--only NAME --input INDEX` repeats that case. The leaf scope is ALU, flags and branches; dead reads and fault equivalence remain follow-ups, and calls, shared callees and tail jumps are in `cpu_aot_fuzz_calls` below. A case worth keeping can be reduced to a fixed fixture with the existing `cpu_asm_fixture` and `cpu_translation` helpers. + +`cpu_aot_fuzz_frames` runs the same comparison on generated functions with fixed RSP frames (`--area frames`), from its own seed, so the leaf smoke above is unchanged. Each function saves one to three of RBX, RSI, RDI and R12 to R15 with `PUSH`, or saves RBX and RSI into home space with `MOV` before `PUSH RDI`, as MSVC does at `/O2`. It then allocates 16 to 40 bytes with `SUB RSP` and keeps RSP 16-byte aligned. The prologue carries the matching `.pushreg`, `.savereg` and `.allocstack` directives. Each saved register is overwritten from RCX and RDX before it is used, because the translator rejects any read of a nonvolatile register's entry value. A 16-byte region of the allocation is filled by a random sequence of 8-, 4-, 2- and 1-byte stores from registers or immediates. Some functions then add a register to a piece of the region in place, or overwrite one or two bytes on either side of a branch. Four to six reloads read 1, 2, 4 or 8 bytes at an offset within the region, zero- or sign-extended. The first is placed across a boundary between two stores. Every reloaded value goes to the output buffer and into RAX. The function restores the saved registers with `MOV` or `POP` and releases the frame with `ADD RSP`. The default run uses seed `0xF4A3` and 16 functions: 5 home-space saves, 90 stores into the regions and 82 reloads, of which 19 are 8-byte, 23 are 4-byte, 24 are 2-byte and 16 are 1-byte. Of the reloads, 44 span two or more stores (at least one in each function), 33 read part of one store and 5 read one store exactly. Nine functions have a branch and 9 have an in-place add. It makes 10,016 native, default and `/O2` comparisons in about 0.3 s. A planted translator fault must be detected: `--mutant` translates the same exports with every frame reload narrower than 8 bytes moved one byte higher in the frame array. The test fails unless that build differs from native. At the default seed, 4,945 of 5,008 calls differed, in all 16 functions. Passing the clean translation as `--mutant` fails with `the planted translator fault was not detected`, and passing the mutant as the translation fails at the first mismatch with the reproduction command. A dropped register restore would not serve as the planted fault, because the generated locals are not the physical registers (see `cpu_aot_stack_frames`). `CPU_FUZZ_FRAMES_SEED` and `CPU_FUZZ_FRAMES_FUNCTIONS` select a longer run. Seeds `0x1`, `0x2`, `0xBEEF` and `0xCCD1` at 128 functions each made 80,128 comparisons per seed in about 1.2 s, with no refusal and no mismatch; 1,450 of their 2,578 reloads span two or more stores. The generator does not use an RBP frame pointer, `LEAVE` or a mid-body RSP change; calls are covered by `cpu_aot_fuzz_calls` below. Run `ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_frames$' -V`. + +`cpu_aot_fuzz_calls` runs the same comparison on generated chains of direct calls, callees shared between callers and tail jumps (`--area calls`), from its own seed, so the smokes above are unchanged. The generator first builds a pool of seven callees that no export names. Each has its own unwind entry, and callee *i* only calls a callee below it, so the pool has no cycles. Three are frameless leaves (an LEA, ADD, XOR and ROL mix; a CMP and JB branch that returns the absolute difference; a 32-bit LEA and ROL that writes EAX), one returns only AL, one stores its result into its own word of the output buffer through R8, and two have a frame that calls one or two lower callees and combines the results, one holding RDX in a pushed register and one in a spill slot above the callee's home space. The sixteen exported functions cycle through six shapes. Eight are call chains of two to four calls from a frame that keeps the output pointer, x and y in pushed registers or a spill slot, reloads RCX, RDX and R8 before each call, widens a byte-sized return with MOVZX and feeds each result into the next call's arguments. Five of those shapes may skip a call behind a TEST and JZ on the saved x, and three functions do. Eight are tail jumps (three, three and two of the forms below): ADD and XOR on the arguments and then a JMP to a callee, the same after `MOV`, a store through R8 and `POP RBX`, or two JMPs to different callees in the two arms of a TEST and JNZ. A callee that returns only AL is never a tail target, because the caller's RAX would keep undefined upper bytes. The default run uses seed `0xCA11` and 16 functions: 7 callees, 23 call sites (20 in the exports and 3 in the callees) and 10 tail jumps, reaching every callee between 2 and 7 times in total, and the callees nest two deep. It makes 10,016 native, default and `/O2` comparisons of RAX and the 256-byte output buffer. A planted translator fault must be detected: `--mutant` translates the same exports and then passes RDX before RCX at every direct call and tail jump in the emitted C++. The test fails unless that build differs from native, and fails with `the planted translator fault was not detected` when the clean translation is passed as `--mutant`. Without MSVC, the same seed was run on Linux with `llvm-ml-19`, `lld-link-19`, a MinGW build of the translation (at `-O0` and `-O2`) and a small loader under Wine: 5,008 native against translated comparisons per build with no mismatch, and the planted fault differed in 3,711 of 5,008 calls, in 13 of the 16 functions. The `ctest` run on Windows with MSVC is not yet recorded here. Run `ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_calls `CPU_FUZZ_CALLS_SEED` and `CPU_FUZZ_CALLS_FUNCTIONS` select a longer run. Dead reads, fault equivalence and RBP frame pointers remain follow-ups. ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Restore the calls command without duplicating the document tail** Following the new reproduction instructions leaves the shell with an unterminated quote: the command stops at `-R '^cpu_aot_fuzz_calls ` rather than providing the complete regex argument (`ctest --help` documents `-R <regex>` as “Run tests matching regular expression”). The `-V` fragment appears at line 7025, after an accidental 4,920-line copy of the remaining experiment notes, which then repeat starting at line 7028. Remove the extra copy and restore `ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_calls$' -V` so contributors can reproduce the new experiment without navigating duplicated documentation. AGENTS.md reference: [AGENTS.md:L153-L156](https://github.com/R0Y00/Xbox2Windows/blob/f8407ade24da7f91b34a0a58982a7b3524980476/AGENTS.md#L153-L156) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
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
R0Y00/Xbox2Windows!1122
No description provided.