WIP: test(lift): the whole-function check without the game, over made-up functions #1592
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1592
Loading…
Reference in a new issue
No description provided.
Delete branch "dyst/Longshot:test/leaf-free"
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?
Type: test · Risk: low · Tested on: Windows 11, Ryzen 9 3900X · Needs: a Linux run
Stacked on #1570 (it reuses that check's instruction draw and known list); review that first.
TL;DR
nx2/test_leaf.pychecks whole translated functions against Unicorn, an AArch64 emulator, but it takes its functions from the game's own code, so the checks skip it everywhere. This makes the functions up instead, from a seeded generator: branches, loops, frames, calls, tail calls and float runs. It translates them through the same steps a real build uses, then compares every register and the memory they wrote. It runs with no game in about 40 s and catches five translator breaks made by hand.Breakdown
tests/test_leaf_free.py(new).Why
The CPU rework plan's milestone C0: before the translator's passes are restructured, a game-free check must run whole functions through the production emitter. Two passes now go through it that
nx2/test_leaf.pyleaves out: the fast float regions and the entry hooks.What changed
tests/test_leaf_free.py(new):Lifting: the passes
nx2/lift.pyinstalls, in its order. It compiles with the translated code's flags fromnx2/build.py(A64_POLLING,A64_WRITE_TRACK) on the 64-bit guest window.The image: a synthetic
EdenImage, made the waytests/test_walk.pymakes one, which the translator discovers as it would the game's.The functions: straight runs of instructions drawn as #1570 draws them, leaving out the forms its known list names and Unicorn's signed LSE min/max bug, plus control-flow shapes:
Loads and stores address a scratch area only. Flags are read only where every path has set them (the AAPCS64, as the translator's dead-flag pass assumes).
Compared, as
nx2/test_leaf.pycompares: X0-X30, SP, V0-V31 and every scratch page that changed. FPSR is reported apart (--fpsrmakes it fail). It also checks that every written page outside the stack has its write-watch mark, that the entry hooks' call counts equal Unicorn's entries, and that no function halted.A failure prints the function's disassembly, the state and the differing registers (
--show-cadds the translated C), keeps its build folder and exits 1.Measurements
Verdict: nothing to measure: a check only.
Flags and settings
None.
Testing
Tested: on Windows 11 with the Builder's Python 3.14 and clang (llvm-mingw). The default run (300 roots, 94 callees, 11,739 instructions) passes: 1,176 comparable cases, 0 differences, about 40 s on an idle PC. Each of five breaks made by hand fails it, each restored afterwards:
nx2/insn.pynx2/lift_fixes.py's entry goto left outNot tested: Linux;
tests/run_all.pyin full.Must be tested: Linux, any PC:
python -I -B tests/test_leaf_free.py(Test Farm: linux).Risks
What could break: nothing in the game. A slow PC takes longer (
--countsets the size;--jobscompiles in parallel).Turning it off: revert the commit.
Compatibility: nothing changes.
Checklist
Everyone
type(scope): description) of the status line's type.can't be run by hand is in Testing's Not testable by hand, with why.
in Risks.
main. On #1570, on310e7c9d.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named). This check passes; the full suite not run yet.third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.🤖 Generated with Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.