Repository navigation
test(relinker): check MOVBE stores to RSP-relative memory and RSP operands - #22429
SchmashinPrunes wants to merge 2 commits into
Conversation
…rands The lowering execution harness now reads back the stack slot at [rsp+0x40] after the stub runs, so the MOVBE test checks what a store to RSP-relative memory writes instead of skipping it. The test also runs RSP as the register operand, which the lowering handles in separate paths for stores and loads, and checks that loads leave memory unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 267c1e0500:
- Conventions:
tools/check_conventions.pypassed. - Build:
movbe_lowering_testsbuilt cleanly. - CTest (
movbe_lowering):1/1 Test #5752: movbe_lowering ................... Passed 0.08 sec 100% tests passed, 0 tests failed out of 1 - Code reading:
- Checked LoweringExecution.hpp: State struct layout offsetof(State, StackMemory) == 50 * 8 and offsetof(State, InputFlags) == 49 * 8 verified by static_assert
- Checked LoweringExecution.hpp stub epilogue assembly sequence: rip offset and memory move instructions correctly load and record [rsp+0x40] into State::StackMemory without clobbering other state fields
- Checked MovbeLoweringTests.cpp: register exclusion (reg == 4 was RSP) removed, allowing reg 4 (RSP) to be exercised across 16-bit, 32-bit, and 64-bit widths and all addressing forms for both loads and stores
- Checked MovbeLoweringTests.cpp: stack store verification trial.StackMemory is correctly tested against expected swapped value (swapped(trial.Input[reg], width)) and load invariance against initial memory value
- Checked docs/dev/debt/changes/test-movbe-stack-operands.md technical debt fragment syntax and rules against AGENTS.md conventions
Looks Good To Me
|
Windows result for head Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release,
AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine. |
|
Tested
AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports. |
The skipped-leaf check executed "leaf reading rsp through movbe" on every host, so red_zone_framer_execution raised SIGILL on CPUs without MOVBE, such as Sandy Bridge. Mark the leaf with hostHasMovbe() as the BMI1 leaf is marked with hostHasBmi1(), and have verifySkippedLeaves skip executing a leaf the host cannot run, as runLeaves already does. The framing checks still cover every leaf. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks to @maskym and @ycbuzi for the runs. The QEMU runs showed The This comment was written by Claude Code, an AI assistant, at my request. |
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 9ccd1407b9:
- Conventions:
tools/check_conventions.pypassed. - Build:
movbe_lowering_tests,red_zone_framer_execution_testsbuilt cleanly. - CTest (
movbe_lowering,red_zone_framer_execution):1/2 Test #5888: movbe_lowering ................... Passed 0.06 sec 2/2 Test #5909: red_zone_framer_execution ........ Passed 0.06 sec 100% tests passed, 0 tests failed out of 2 - Code reading:
- Verified LoweringExecution.hpp: State struct layout offsetof(State, InputFlags) == 49 * 8 and offsetof(State, StackMemory) == 50 * 8 confirmed by static_assert and matching the stub assembly offsets
- Verified LoweringExecution.hpp stub epilogue correctly reads [rsp+0x40] from the simulated stack frame into State::StackMemory without clobbering caller-preserved registers or flags
- Verified MovbeLoweringTests.cpp: exclusion for reg == 4 (RSP) was safely removed, enabling load and store coverage of RSP register operands across 16, 32, and 64-bit widths and addressing forms
- Verified MovbeLoweringTests.cpp: stack store verification trial.StackMemory is correctly verified against swapped(trial.Input[reg], width) and loads verify that memory is left unaltered
- Verified RedZoneFramerExecutionTests.cpp: hostHasMovbe() properly guards the MOVBE instruction sequence using __builtin_cpu_supports("movbe") so older hosts without MOVBE (e.g. Sandy Bridge) skip execution cleanly without SIGILL
- Verified docs/dev/debt/changes/test-movbe-stack-operands.md technical debt fragment matches required format and adheres strictly to AGENTS.md rules
Looks Good To Me
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
The pinned head is 9ccd1407b9cd82088ae3bcd03337b9d65e48fd79; I inspected all four changed files, and the described test changes appear consistent with the harness and host-feature gating.
What I ran
No commands or tests were run. I read the prepared diff and the complete head text for all changed files.
Results
| Check | Result | Note |
|---|---|---|
| Changed-file review | passed | All four changed files read |
| Tests | not run | Author-reported results not independently verified |
Findings
Blocking
None.
Non-blocking
None.
Not verified
The author reports passing tests and mutation checks, but I did not run them. review/files.json was not available through the reader, so excluded-file details were not independently checked; the manifest lists four changed files, and all four full texts were read.
To get this to a good state
Nothing is required.
|
Retested head Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, The tests this PR adds or extends, AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine. |
|
Re the overlap note on #18293: checked by hand. Both PRs touch This comment was written by Claude Code, an AI assistant, at my request. |
|
Thanks to @maskym and @ycbuzi for the test runs on this one. I'm closing it for now to free my one open PR slot for the FMA lowering under This comment was written by Claude Code, an AI assistant, at my request. |
What
The MOVBE lowering test ran every form against
[rsp+0x40]but checked the result only for loads: the shared lowering execution harness wrote the slot before the stub and never read it back, so a store to RSP-relative memory was not checked. Those stores are where the stub has to add its 160-byte spill frame back into the displacement. The test also skipped RSP as the register operand, whichEmitMovbehandles in separate paths (leaof RSP for a store,_writeStackPointerfor a load), so neither path ran.LoweringExecution.hpp:Stategets aStackMemoryfield, which the harness fills with the stub's[rsp+0x40]after it runs. It is added at the end, so existing offsets stay the same (checked with astatic_assert), and the other five tests that use the harness are unchanged.MovbeLoweringTests.cpp: stores to[rsp+0x40]are checked like the other stores. RSP now runs as the register operand for every width and addressing form. Loads are also checked to leave memory unchanged.RedZoneFramerExecutionTests.cpp: the test executed its "leaf reading rsp through movbe" case on every host, sored_zone_framer_executionraised SIGILL on CPUs without MOVBE, such as Sandy Bridge, as the QEMU runs in the test report on this PR show. The leaf is now marked withhostHasMovbe(), as the BMI1 leaf is marked withhostHasBmi1(), andverifySkippedLeavesskips executing a leaf the host cannot run, asrunLeavesalready does. The framing checks still cover every leaf.Test-only change:
MovbeLowering.cppis not modified, and the new cases pass on it.Tested
Debian (Linux x86-64), GCC 14.2, Ninja, Release,
-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON:ctest --test-dir build-relinkerpassed 966/966. No title tested.red_zone_framer_executionunderqemu-x86_6410.0.13: before this PR, SIGILL atmovbe [r9], rspwith-cpu SandyBridgeand-cpu Westmere; after it, passes with-cpu SandyBridge(the MOVBE leaf is reported as not executed) and with-cpu Haswelland-cpu max(the leaf runs). It also passes natively.To check that the new cases detect errors, I injected each of these faults into
MovbeLowering.cppand ran both this test and the one onmain(not committed):mainMOVBE store 16 reg 0 tail 132: memory is …MOVBE store 16 reg 4 tail 6: memory is …MOVBE load 32 reg 4 tail 6: register 4 is …python3 tools/check_conventions.py --base upstream/mainpasses, andpython3 tools/pr_overlap.py --branch test/movbe-stack-operandsreports no overlap.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code