mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:30:53 +01:00
[PR #1780] cf_ref: validate mask widths, integer/export/branch modifiers, EXEC=0 operands, and duplicate PCs (CF-REF-OPERAND-VALIDATION) #1791
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1791
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1780
Author: @ShotTechOp
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/cf-ref-validation📝 Commits (1)
3df0d83cf_ref: validate mask widths, integer/export/branch modifiers, EXEC=0 operands, and duplicate PCs (CF-REF-OPERAND-VALIDATION)📊 Changes
2 files changed (+213 additions, -70 deletions)
View changed files
📝
tests/test_cf_ref.py(+82 -0)📝
tools/cf_ref.py(+131 -70)📄 Description
Summary
Claimed in #1608 as
CF-REF-OPERAND-VALIDATION: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161734635Hardens
tools/cf_ref.py(WaveMachine) so malformed or unsupported control-flow, mask, integer, export, and branch operands raisecpu_ref.Unsupported/cpu_ref.ProgramErrorinstead of silently truncating, wrapping, or skipping validation whenEXEC == 0:_read_mask,_write_mask):width(32or64, defaulting toself.waveso subclasses liketools/wave_diff.pystay compatible).n != 2on 64-bit mask ops/compares such ass0ors[0:3];n != 1on 32-bit mask ops/compares such ass[0:1]), and reject 32-bit*_lo/*_hispecial mask registers on 64-bit ops (s_mov_b64,s_<op>_b64,s_*_saveexec_b64, wave64v_cmp_*).exec_hiread-as-0 / ignored-write andvcc_hiscalar behaviour covered bytests/test_cf_ref_edge_fixes.py.EXEC == 0:_check_vgpr_dst) and integer sources (_check_int_src) before the active-lane loop inv_add_nc_u32,v_sub_nc_u32,v_subrev_nc_u32,v_mul_lo_u32,v_mbcnt_lo_u32_b32,v_mbcnt_hi_u32_b32, wave32 VOP2v_cndmask_b32, andv_cmp_*/v_cmpx_*.abs/negand multi-dword operands on integer, mask, and export ops:abs/negmodifiers on mask operands, scalar destinations, integer sources, andexp mrt0operands, plus multi-dword VGPRs onexp mrt0and integer vector ops.simm16range/modifier checks and duplicate PC guard:abs/negmodifiers and out-of-range offsets outside[-32768, 65535]in_branch.ProgramErroron duplicate instruction PCs inWaveMachine.__init__.Independent of
#1457(tools/cpu_ref.py); zero PR dependencies and zero file overlap.Testing
Environment: Windows 11 x64, Python 3.12.10, CPU-only (no GPU or game files; rebased on
0d80bc5).python -I tests/test_cf_ref.py-> 31/31 OK (negative control on0d80bc5tools/cf_ref.py: 42 failures, 1 error across the 5 new regression tests)python -I tests/test_cf_ref_edge_fixes.py-> 5/5 OKpython -I tests/test_wave_diff.py-> 12/12 OKpython -m compileall -q tools/cf_ref.py tests/test_cf_ref.py-> exit 0python -I scripts/check_no_game_data.py tools/cf_ref.py tests/test_cf_ref.py-> exit 0git diff --check-> cleanAI-assisted: yes (Antigravity). Synthetic inputs only; no game data.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.