mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:45:54 +01:00
[PR #808] [MERGED] cfg_structure / rdna2spirv: unwrap tautological %pc guards in structured CFGs (ms_wave_info_s3 AMD crash, SHADER-STRUCTURED-PC-UNWRAP) #846
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#846
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/808
Author: @whoalin1
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142
Base:
main← Head:shader-structured-pc-unwrap📝 Commits (4)
0681b9dcfg_structure / rdna2spirv: unwrap tautological %pc guards in structured CFGs (ms_wave_info_s3 AMD LLPC crash)53ef382cfg_structure: document why loop entry keeps cur_pc | {h} in unwrap_known_pc_guards8e5cf5afix(rdna2spirv): include END in out_pcs for trailing conditional branches33431d6fix(wave64_emulate_opt): refuse exec-fold regions containing a trailing conditional branch📊 Changes
7 files changed (+337 additions, -79 deletions)
View changed files
📝
docs/design.md(+1 -1)➕
tests/semantic/test_structured_pc_unwrap.py(+186 -0)📝
tests/test_cfg_structure.py(+39 -0)📝
tests/test_translate.py(+5 -0)📝
tools/cfg_structure.py(+66 -2)📝
tools/rdna2spirv.py(+26 -4)📝
tools/wave64_emulate_opt.py(+14 -72)📄 Description
Claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7133575269 (
SHADER-STRUCTURED-PC-UNWRAP)Problem
On AMD's proprietary Windows Vulkan driver (
24.10.24, LLPC, AMD Ryzen 5 7600 RDNA2 iGPU, native wave64),ms_wave_info_s3segfaults (0xC0000005) duringvkCreateGraphicsPipelines.In
ms_wave_info_s3.asm,blk0conditionally skipsblk1(MSG_GS_ALLOC_REQ), and bothblk0andblk1converge atblk2(s_barrier).cfg_structure.structure()wrapsblk2in("guard", 2, [("block", 2)]), emittingOpBranchConditionalaround%blk2'sOpControlBarriereven though%pc == 2is tautologically true on every incoming path.--wave64-emulate(e.g., 32-wide NVIDIA GPUs),wave64_emulate_opt._unwrap_known_pc_guardsalready unwrapped that guard, soms_wave_info_s3passed there.rdna2spirv.capped_tree()usedcfg_structure.structure()directly without unwrapping tautological%pcguards, leavingOpControlBarrierinside conditional control flow and crashing AMD Windows LLPC (0xC0000005).Fix
tools/cfg_structure.py: addunwrap_known_pc_guards(tree, out_pcs, entry_pc=0)(moved fromtools/wave64_emulate_opt.py, keepingcfg_structure.structure()unchanged for callers like_drop_sink_block).tools/wave64_emulate_opt.py: delegate_unwrap_known_pc_guardsdirectly tocfg_structure.unwrap_known_pc_guards.tools/rdna2spirv.py(capped_tree): applycfg_structure.unwrap_known_pc_guardsto structured trees before computing nesting depth, so bothassemble()andneeds_barrier_rounds()see post-dominating merge/barrier blocks at top level.tests/test_cfg_structure.py: addtest_unwrap_known_pc_guards(single-arm if-then, diamond, loop exit, early-exit guard preservation) and differentially checkunwrap_known_pc_guardsacross all 18,228 random reducible graphs × 6 seeds.tests/test_translate.py: assert%blk2inms_wave_info_s3is emitted without a conditional%pcguard before itsOpControlBarrier.docs/design.md: document the pass in the Control flow contract row.Verification (before/after on
main47c651174,LEONIDA_VK_VALIDATION=1)LEONIDA_PC_TAIL_UBO=1):main):ms_wave_info_s3FAIL (vk_harnesscrash0xC0000005)ms_wave_info_s3PASS (4096/4096 pixels exact, 0 validation errors);cs_barrier_divergent,cs_barrier_early_end,cs_barrier_loop3/3 PASSms_wave_info_s3PASS (4096/4096 pixels exact, 0 validation errors);cs_barrier_*3/3 PASSpython -I tests/test_cfg_structure.py— 18,228 random reducible graphs × 6 seeds (both structured and unwrapped trees matchwalk()), plus shape & deep-chain testspython -I tests/test_runner_calls_all_tests.py— 3/3 OKpython -I tests/test_cfg_run_limit.py— 4/4 OKpytest tests/test_translate.py— 669 passedunittest discover -s tests/semantic -p test_wave64_emulate_opt.py— 31/31 OKunittest discover -s tests/semantic -p "test_*barrier*.py"— 53/53 OKunittest discover -s tests/semantic -p "test_exec*.py"— 2/2 OKunittest discover -s tests/semantic -p "test_ms_*.py"— 6/6 OKpython -I tests/test_text_write_line_endings.py— 3/3 OKpython -I scripts/check_no_game_data.py ...— clean (rc=0)AI-assisted (Gemini 4 Neon).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.