cpu: recompile a caller that repeats one direct call #176
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/177"
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:00:48Z.
Change
cpu_call_aotaccepted exactly one call per caller, and the direct-call section listed "one direct call" as a coverage limit. It now accepts repeated direct calls that share one target, and lifts that callee once. A second distinct target is rejected, and import calls stay limited to one per caller.Only RBX and RSI survive a call in this profile, so a caller that calls twice must keep its output pointer in one of them. The translator now decodes 64-bit moves between R8 and the profile registers. It handles both the opcode 8B form that ML64 emits (
49 8B F0,4C 8B C6) and the opcode 89 form (4C 89 C6,49 89 F0). It tracks which registers still hold the entry R8 value, so R8 can only be reloaded from such a copy. Every[r8+disp]store therefore still goes to the caller's trace. After a call, R8 is undefined until it is reloaded.The new source-built fixture
tests/cpu/repeat_call.asmhas a callercall_twicethat parks R8 in RSI. Its second call takesfirst + xandx, so it depends on the first result. The callee has the same body asmix_argsindirect.asm.direct.asmand its check are unchanged.Verification
Commit
e27cfe9onecb9160. Windows 11 build 26200, MSVC 19.50.35720 with ML64, Windows SDK 10.0.26100.0, Python 3.13.cpu_aot_direct_call.mov r8, rsi("undefined register");mov r8, rsipatched tomov r8, rbx, where RBX holds an input word ("R8 reloaded without the output pointer"). Without the pointer tracking, this copy translated and its stores would have used an integer as the trace address.mainrejectscall_twiceatmov rsi, r8with "unsupported or incomplete instruction".cpu_call_original,cpu_call_altered,cpu_import_originalandcpu_ordinal_originalsources are byte-identical before and after the change.ctest --preset dev --no-tests=erroron an RX 9070 XT (driver 32.0.32015.7029) gives 103 tests: 100 passed, 2 capability skips (bvh_wave64_warp,wave_shuffle_warp) and 1 failure. The failure ispixel_aot_hardware, which also fails onmainat583fee5without this change, with the same first mismatch. The failing case is the comparison-predicate draw added in #158:v_cmp_nlg_f32with a NaN operand returns 0 on that adapter, whilepixel_aot_warppasses. This change touches no shader code.Evidence and follow-up
The 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 command. The fixture exercises the R8 moves only through RSI. Two calls to different callees would need the translator to lift and name more than one callee, and remain open. Follows the direct-call work in #22.Checklist
AI-assisted (Claude Code).