test(relinker): run the lowering execution checks on Windows #17548

Merged
ycbuzi merged 2 commits from upstream-pr/17548 into main 2026-11-12 23:30:22 +00:00
ycbuzi commented 2026-11-08 21:39:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-11-08T21:39:53Z.


What

The lowering tests' execution parts were compiled out on Windows: LoweringExecution.hpp only mapped pages with mmap/mprotect and called the generated wrapper with the host calling convention. This makes them run on Windows x86-64 with GCC or Clang:

  • pages come from VirtualAlloc/VirtualProtect (plus FlushInstructionCache), behind small AllocatePages/ProtectPages/FreePages helpers that keep using mmap on Linux and macOS;
  • on Windows the code page also gets a 22-byte entry bridge that keeps rsi and rdi (callee-saved there), passes the argument in rdi where the wrapper reads it, and keeps the stack aligned, so no compiler extension is needed (the first version used sysv_abi, which the current conventions check rejects);
  • the four "execution checks require a Linux/macOS x86-64 build" messages now name Windows too.

The ANDN, BLS, bitfield and shift tests on main pick this up. MULX already had its own Windows path, and the masked store test keeps its own Linux/macOS guard (it needs SIGSEGV handling). The approach is @gabichuuuuu's, from the review of #17132; credit is in the commit message.

Overlap: #16236 (also mine) adds a POSIX-only HostExecutes under the same LOWERING_EXECUTION_AVAILABLE guard. Whichever of the two lands second, I'll update the other so HostExecutes stays out of the Windows build (or gets a Windows probe).

Tested

Windows 11, i7 (BMI1/2), WinLibs GCC 15.2 UCRT, Release, -DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON, head 055b22208f (this PR with main 22ae9a397d merged):

  • andn_lowering, bls_lowering, bitfield_lowering, shift_lowering: pass 3 of 3 runs each, and none prints the skip message any more, so their execution parts ran. mulx_lowering (73,868 cases) and masked_store_lowering pass unchanged.
  • Negative control: with the ANDN lowering's AND (0x23) changed to OR (0x0B), andn_lowering_tests.exe fails on Windows with "ANDN changed a source/scratch register or produced an incorrect result". It passes again once restored.
  • Linux: Debian 13 x86-64 (Intel N6000, no AVX), GCC, Release, relinker-only, head 055b22208f (checked to contain this PR's helper): andn_lowering, bitfield_lowering, bls_lowering, shift_lowering and mulx_lowering (73,868 cases) pass in 3 of 3 runs each, so the moved mmap/mprotect/munmap path still works. (An earlier version of this description listed Linux runs that had tested main by mistake; these replace them.) masked_store_lowering isn't affected here: it doesn't include this helper and needs an AVX host.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5215375416 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17548). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-11-08T21:39:53Z. --- ### What The lowering tests' execution parts were compiled out on Windows: `LoweringExecution.hpp` only mapped pages with `mmap`/`mprotect` and called the generated wrapper with the host calling convention. This makes them run on Windows x86-64 with GCC or Clang: - pages come from `VirtualAlloc`/`VirtualProtect` (plus `FlushInstructionCache`), behind small `AllocatePages`/`ProtectPages`/`FreePages` helpers that keep using `mmap` on Linux and macOS; - on Windows the code page also gets a 22-byte entry bridge that keeps `rsi` and `rdi` (callee-saved there), passes the argument in `rdi` where the wrapper reads it, and keeps the stack aligned, so no compiler extension is needed (the first version used `sysv_abi`, which the current conventions check rejects); - the four "execution checks require a Linux/macOS x86-64 build" messages now name Windows too. The ANDN, BLS, bitfield and shift tests on `main` pick this up. MULX already had its own Windows path, and the masked store test keeps its own Linux/macOS guard (it needs SIGSEGV handling). The approach is @gabichuuuuu's, from the review of #17132; credit is in the commit message. Overlap: #16236 (also mine) adds a POSIX-only `HostExecutes` under the same `LOWERING_EXECUTION_AVAILABLE` guard. Whichever of the two lands second, I'll update the other so `HostExecutes` stays out of the Windows build (or gets a Windows probe). ### Tested Windows 11, i7 (BMI1/2), WinLibs GCC 15.2 UCRT, Release, `-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON`, head `055b22208f` (this PR with `main` 22ae9a397d merged): - `andn_lowering`, `bls_lowering`, `bitfield_lowering`, `shift_lowering`: pass 3 of 3 runs each, and none prints the skip message any more, so their execution parts ran. `mulx_lowering` (73,868 cases) and `masked_store_lowering` pass unchanged. - Negative control: with the ANDN lowering's `AND` (0x23) changed to `OR` (0x0B), `andn_lowering_tests.exe` fails on Windows with "ANDN changed a source/scratch register or produced an incorrect result". It passes again once restored. - Linux: Debian 13 x86-64 (Intel N6000, no AVX), GCC, Release, relinker-only, head `055b22208f` (checked to contain this PR's helper): `andn_lowering`, `bitfield_lowering`, `bls_lowering`, `shift_lowering` and `mulx_lowering` (73,868 cases) pass in 3 of 3 runs each, so the moved `mmap`/`mprotect`/`munmap` path still works. (An earlier version of this description listed Linux runs that had tested `main` by mistake; these replace them.) `masked_store_lowering` isn't affected here: it doesn't include this helper and needs an AVX host. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
gabichuuuuu commented 2026-11-08 22:00:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-08T22:00:53Z.

Review: COMMENTED


Windows run of head 15c43ef4f1, merged onto main 0bae53facd in one tree with eight other open PRs that touch different files (all nine merged cleanly). Setup: Windows 11, WinLibs GCC 15.2 r7 (x86_64-ucrt-posix-seh, the CI toolchain), Release, BUILD_TESTING=ON.

  • andn_lowering with --repeat until-fail:5: 5 / 5 pass.
  • bitfield_lowering with --repeat until-fail:5: 5 / 5 pass.
  • bls_lowering with --repeat until-fail:5: 5 / 5 pass.
  • shift_lowering with --repeat until-fail:5: 5 / 5 pass.

On main these execution checks compile out on Windows (LOWERING_EXECUTION_AVAILABLE is 0 there). With this PR they run the generated code through VirtualAlloc/VirtualProtect and the sysv_abi entry, and all four pass.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5819850278 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17548#pullrequestreview-5819850278). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-08T22:00:53Z. **Review:** COMMENTED --- Windows run of head `15c43ef4f1`, merged onto `main` `0bae53facd` in one tree with eight other open PRs that touch different files (all nine merged cleanly). Setup: Windows 11, WinLibs GCC 15.2 r7 (`x86_64-ucrt-posix-seh`, the CI toolchain), Release, `BUILD_TESTING=ON`. - `andn_lowering` with `--repeat until-fail:5`: 5 / 5 pass. - `bitfield_lowering` with `--repeat until-fail:5`: 5 / 5 pass. - `bls_lowering` with `--repeat until-fail:5`: 5 / 5 pass. - `shift_lowering` with `--repeat until-fail:5`: 5 / 5 pass. On `main` these execution checks compile out on Windows (`LOWERING_EXECUTION_AVAILABLE` is 0 there). With this PR they run the generated code through `VirtualAlloc`/`VirtualProtect` and the `sysv_abi` entry, and all four pass.
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
boykopovar/AnyPS5!17548
No description provided.