mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:30:52 +01:00
[PR #1414] spirv_opt: enforce Result Type match on int/load folding and pin OpDecorateId operands from DCE (SPIRV-OPT-TYPE-DECORATE-SOUNDNESS) #1443
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#1443
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/1414
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/spirv-opt-type-and-decorate-soundness📝 Commits (2)
fad7435spirv_opt: enforce Result Type match on int/load folding and pin OpDecorateId operands from DCEd9a6e2atest_spirv_opt: use OpShiftLeftLogical instead of invalid mixed-type OpBitFieldUExtract in fixture📊 Changes
2 files changed (+116 additions, -12 deletions)
View changed files
📝
tests/test_spirv_opt.py(+95 -0)📝
tools/spirv_opt.py(+21 -12)📄 Description
Item ID:
SPIRV-OPT-TYPE-DECORATE-SOUNDNESSSummary
Fixes two SPIR-V soundness bugs in
tools/spirv_opt.py:_fold_int_op,_optimize_function): SPIR-V permits signed (%int) and unsigned (%uint) operands inOpIAdd,OpISub,OpIMul,OpBitwiseAnd,OpBitwiseOr,OpBitwiseXor, shifts, andOpBitFieldUExtractwhoseResult Typehas the opposite signedness. Previously_fold_int_opreturned operand SSA IDs directly (e.g.%u = OpIAdd %uint %s %u0folded to%sof type%int, and%u = OpIMul %uint %u %i0folded to%i0), producing invalid SPIR-V with mismatched types.* 0,& 0,| ~0,0 << x,0 >> x) now look upint_const_by_val.get((res_ty, ...))so they fold to theResult Type's constant when available._fold_int_opaliasing andOpLoadslot forwarding now guardid_type.get(folded) == args[0], andconst_typealso recordsOpUndef/OpSpecConstant*types without marking them as compile-time constants.OpDecorateIdoperand IDs after DCE (_optimize_function,optimize):OpDecorateId %target <Decoration> %operandpreviously protected%operandfrom folding/CSE viadecorated_ids, but backward DCE could still delete%operandwhile leavingOpDecorateIdin the module header (header cleanup only dropsOpDecorateIdwhentoks[1], the target, is deleted). Operand IDs inOpDecorateId'sargs[2:]are now tracked inpinned_idsand excluded from DCE.Tests & Verification
python3 -m compileall -q make_game.py tools tests— OKpython3 -I scripts/check_no_game_data.py tools/spirv_opt.py tests/test_spirv_opt.py— OKpython3 -I tests/test_spirv_opt.py -v— 14/14 OKpython3 -I scripts/run_semantic_tests.py tests/semantic— 475 files, 6220 tests, 0 files failed in 65 spython3 -I tests/test_text_write_line_endings.py— 3/3 OKpython3 -I tests/test_ci_registration.py— 16/16 OKtests/test_spirv_opt.pyon unpatchedupstream/main): 2 failures (FAILED (failures=2)).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.