cpu: recompile a caller with two different direct callees #220
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/223"
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 R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-21T18:35:48Z.
Change
Advances: an independent problem in the CPU call profile. It follows #177, which left "two calls to different callees" open. There is no prerequisite PR: #219, which this was reconciled with as requested in review, is now merged, so the branch is a single commit on current
main.In
cpu_call_aotwith this change, a caller may:lifted_callee, and later ones arelifted_callee2,lifted_callee3and so on.Still rejected, in either order:
The new source-built fixture
tests/cpu/call_pair.asmhas a callercall_pairthat callsmix_args(a - b + 11) and thenmix_other((a ^ b) + 29). The XOR keeps the two callees from commuting, so swapping the calls changes the result.repeat_call.asmwith #219'sIMPORT_MIXbuild anddirect.asmare unchanged by this PR.Changed expectations in
cpu_aot_repeated_call. All of these cases are still rejected:Verification
Head
971ae91on6254a96(the #219 merge). The full suite ran onfad2d42, which has an identical tree; the five tests below were rerun on971ae91. Windows 11 build 26200, MSVC 19.50.35720 with ML64, Windows SDK 10.0.26100.0, Python 3.13.cpu_repeat_original) and #219's repeated import (cpu_repeat_import), 249 pairs each against native execution.cpu_repeat_importsource is byte-identical to what #219's translator, as merged, produces for the same DLL.cpu_call_original,cpu_call_altered,cpu_import_original,cpu_ordinal_original,cpu_repeat_originalandcpu_repeat_alteredsources are byte-identical tomainbefore #219 and this change.mix_otheraslifted_callee.mix_args, or onlymix_other, changes the caller's return on every pair.mix_argsruntime-function entry is extended intomix_otheris refused by the range reader as an invalid runtime-function interval.mainrejectscall_pairwith "call to a second target".ctest --preset dev --no-tests=errorgives 116 tests, 0 failed.bvh_wave64_warpandwave_shuffle_warpreported capability skips.Not exercised:
Evidence and follow-up
The new fixture is original MASM written for this test (MIT). The README CPU row and the direct-call section of
docs/experiments.mdare updated with the commands and rejection reasons.Checklist
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T18:39:47Z.
Reviewed
b7967799alongside #219. This head rejects a second IAT call before checking its slot, while #219 verifies two calls to the same slot against native execution. Please reconcile with #219 so the caller can use multiple direct targets or repeat one import slot. Keep rejection of distinct IAT slots and mixed direct/import calls in either order. For the combined head, please runctest --preset dev --no-tests=error -R '^cpu_aot_(call_pair|repeated_call|direct_call|import_call|ordinal_import)$' -Vand retain both native differential cases.Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-21T18:46:53Z.
Reconciled with #219. The head is now
90ec8f8on6941bf6: #219's commit (4e820ab, Vonsek's, rebased onto currentmain) with this change on top.Combined behavior:
All 5 pass on Windows 11 build 26200 with MSVC 19.50.35720. Both native differential cases are retained: 249 pairs each for the repeated direct call and for #219's repeated import (
249 repeated-import input pairs match native execution, guarded trace, RBX and RSI).The generated
cpu_repeat_importsource is byte-identical to what #219's own translator produces. The six earlier generated sources are byte-identical tomain. The full suite gives 115 tests, 0 failed, with capability skips forbvh_wave64_warpandwave_shuffle_warp. The PR description lists the changed rejection messages. If #219 merges first, this branch reduces to its second commit.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-21T18:52:57Z.
I independently tested the combined #223 head (
90ec8f8) on Windows x64 andextended its source-built MASM fixture to cover the A -> B -> A sequence
listed in the PR's verification notes.
Across 249 input pairs, the native and recompiled callers matched the
independent arithmetic, including the return value, guarded final trace
and RBX/RSI sentinels. I also checked the linked call sites in both builds.
The first and third instructions call the same target, with a call to the
other target between them. Swapping the first two calls in the native
control (B -> A -> A) changed 244 return values.
After configuring with the dev preset in
out/build/mixed-call-reviewand building the fixtures, I ran this CTest selection:
Result: 5 passed, 0 failed, 0 skipped. The A -> B -> A fixture runs as
part of cpu_aot_call_pair. I can share the source-only test patch if
you'd like to fold it into #223.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T18:55:19Z.
Thanks for retaining both contributors’ work in
90ec8f8. #219 is now on main at6254a96. A three-way merge against that exact commit still reports five conflicts. Since Vonsek’s change is on main, one route is to replay denn0x’s90ec8f8on6254a96, preserving authorship.In
tools/cpu_call_aot.py, reconcile the call-kind check, repeated IAT slot identity and callee declarations. Intests/cpu/repeat_call_check.py, keep the mixed-call controls in both orders and the distinct-IAT-slot rejection. InCMakeLists.txt, keep both the call-pair and EXE-entry tests, and combine the CPU row inREADME.mdand the repeated-call paragraph indocs/experiments.md.Please push the reconciled head. We’ll verify that exact candidate on Windows with
ctest --preset dev --no-tests=error -R '^cpu_aot_(call_pair|repeated_call|direct_call|import_call|ordinal_import|exe_entry)$' -V. The separate A→B→A report is useful additional evidence.Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-21T19:01:58Z.
Thanks for merging. After the merge I ran the requested selection on
mainatf85723e, on Windows 11 build 26200 with MSVC 19.50.35720:Result: 6 passed, 0 failed, 0 skipped.
@RonLogic, thanks for the independent run and the A -> B -> A extension. This closes the second "not exercised" item in the PR body. Since #223 is merged, the fixture would fit best as its own small PR, with the B -> A -> A swap as its negative control.
AI-assisted (Claude Code).