cpu: accept LEAVE on a proven RBP anchor in cpu_switch_aot #907
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#907
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@legacy-code-archaeologist on GitHub · 2026-11-23 16:39 UTC · original
Claim and design question: accept
LEAVEon a proven RBP anchor incpu_switch_aotleaveis in the Integer group ofdocs/coverage/x64_zen2.tsv. No translator accepts it: there is noM.LEAVEintools/. It is the usual frame-pointer epilogue (mov rsp, rbp; pop rbp). Since169289b,cpu_switch_aotproves a fixed RBP anchor aftermov rbp, rsporlea rbp, [rsp+d]. Today any other write of RSP is rejected as a dynamic frame, so a function that ends inleaveis refused. I found no open issue or PR about it and would like to take it as one small PR.Proposed rule (frame proof in
step())LEAVEonly while the RBP anchor is known on every path into it, as the agreeing-at-joins rule already requires for RSP.POP RBPrule:ADD RSPreleases them since7fb6a9a.LEAVEwithout a known anchor. Also reject it when the anchor lies below the current RSP, which would move RSP down instead of releasing the frame.ENTERstays rejected.mov rsp, rbpas a separate instruction also stays rejected, unless you prefer it accepted under the same rule.Proposed fixture (source-built MASM, differential,
; coverage: source cpu_aot_leave)Exports would cover:
push rbp / mov rbp, rsp / sub rsp, Nframe with locals, ending inleave; ret;lea rbp, [rsp+d]anchor form;Native and translated outputs (RAX plus an output buffer) must match over generated inputs. Negative controls must each be rejected with a named message:
leaveafter RBP was overwritten (no anchor);leaveon a path where the anchor differs at a join;leavewhere the saved slot was never written;leave.Question before I start
Is accepting
LEAVEon a proven anchor the intended next step for this translator? Or should frame-pointer epilogues wait for a broader dynamic-frame model? And shouldmov rsp, rbpbe accepted by the same rule in the same PR, or stay rejected?Test host: Intel Skylake (i7-6820HQ) on Windows 11 26100.
AI-assisted (Claude Code).
@R0Y00 on GitHub · 2026-11-23 16:50 UTC · original
Yes, please proceed with LEAVE as a fixed-frame epilogue. Keep ENTER and standalone MOV RSP,RBP outside this PR. Reuse the saved-RBP proof, preserve flags, and invalidate the whole freed interval through anchor+8, including the pop slot. Your fixtures and refusals fit the scope. Please include a saved slot overwritten with ordinary data so the test distinguishes restoring the original RBP from merely reading eight defined bytes. #895 also edits the shared Frame class, so please check that the existing synchronous stack-output cases still pass.
@R0Y00 on GitHub · 2026-11-23 18:27 UTC · original
Completed by #933. The fixed-frame lowering restores RBP from its proven saved slot, frees the stack interval through that slot, and preserves the flags from before LEAVE. The differential and refusal controls passed, including an overwritten saved slot and a 16-bit operand-size override. ENTER and standalone MOV RSP,RBP remain outside this scope.