test: the lifted code's flags stay semantics-safe when its optimization level rises #1140
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1140
Loading…
Reference in a new issue
No description provided.
Delete branch "Marcuss2/Longshot:test/split-exactness"
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: Linux (game-free checks) · Needs: none
Why
The build-time work makes it cheap to compile more of the lifted code at a higher optimization level (a hot-list build went from 7 min 13 s to 3 min 17 s from scratch once the giant hot functions were split). Nothing in the tree states, or checks, the rule that makes that safe: raising the level may change how fast the guest's C runs, never what it computes. Two flags carry that promise, and one wrong flag voids it silently:
-ffp-contract=off: ana*b+cmust round twice as the guest does, not once as an FMA;-fno-strict-aliasing: the lifted code puns pointers constantly.And
RX_HOT_OPT/the hot flags are derived by swapping-O1for-O<n>in the chunk flags, so any-ffast-mathshape that ever reachedflags()orLIGHT_FLAGSwould reach every hot piece with no one noticing.What changed
A new game-free check,
tests/test_lifted_flags_safe.py, locks the flag surface the lifted code is compiled with, so that raising a chunk's or the hot list's optimization level can only make the guest's C run faster, never compute something else. It needs no compiler, no dump and no game: it reads the flags the build itself uses.tests/test_lifted_flags_safe.py: checks the flag surface the lift compiles with.It calls
nx2/build.py's ownflags()andLIGHT_FLAGS(no compiler, no dump, no game): the chunk flags at-O1,-O2and-O3must carry both safe flags and none of fourteen fast-math/float-licence shapes; the hot pieces' derivation must differ from a chunk's flags by the optimization level alone; andLIGHT_FLAGSmust be-mllvm -opt-disable=<names>over a reviewed allowlist of optimization passes, so a semantics option can never be smuggled in as a "pass".Measurements
Verdict: nothing to measure — a test that locks the flag surface; the evidence is that it passes here and that it fails if any of the above changes.
python -I -B tests/run_all.pyon Linux: 587 passed, 17 failed, 74 skipped, the 17 also failing onmain @ 71b1edd8(the known environmental set).Flags and settings
None: the check reads the flags the build already uses and adds no switch.
Testing
Tested:
python -I -B tests/test_lifted_flags_safe.pyandpython -I -B tests/run_all.pyon Linux. The check needs no compiler and no dump, so it runs everywhere, including CI-less checkouts.Not tested: the compiled behaviour itself — that is
tests/test_split_giants.py(the split mechanism) plus the newtests/test_opt_level_exactness.py(hot+split and-O1vs-O2on the same function), which are separate PRs from other workstreams.Must be tested: None.
Risks
What could break: a deliberate addition of a pass to
LIGHT_PASSESnow fails until the allowlist in the test names it — that is the point (a pass list change should be reviewed for float semantics), and the failure message says so.Turning it off: revert the commit; nothing is shipped to players.
Compatibility: Nothing changes for a player.
Checklist
Everyone
type(scope): description) of the status line's type.main(71b1edd8).python -I -B tests/run_all.pypasses (the 17 that fail also fail onmain).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:trailer.WIP: test: the lifted code's flags stay semantics-safe when its optimization level risesto test: the lifted code's flags stay semantics-safe when its optimization level risesPossibly related, for context:
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.