test(shader): use structural dominance in CFG checks #2974
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2974"
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?
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-10T19:09:05Z.
What
Fixes #2960. The control-flow test helper derived structured construct membership from ordinary CFG dominators, which can misclassify a loop merge as part of a nested selection. Compute structural dominators for the helper by including each construct's declared merge edge and each loop's declared continue edge, and use those dominators throughout the structured-branch checks.
The regression builds the six-block #2960 input, runs it through the real
Structurizer, then checks the resulting eight-block graph. The test passes with this helper and fails with the old plain-dominator helper at block 6 branching to block 7 outside the selection.Two open structurizer PRs (#2471 and #2941) also extend
ControlFlow.cpp; they add separate fixtures and changes inStructurizer.cpp. This PR changes only the test helper and its focused regression case.Tested
Linux, GCC 12.2.0, Release: built
agc_shader_control_flow_tests; CTestagc_shader_control_flowpassed (1/1). Replacing the structural-dominator queries with plaingraph.Dominatesmade the new regression fail with the expected diagnostic.python3 tools/check_conventions.py --base upstream/mainandgit diff --checkpassed.Checklist
main; no other open PR implements the same functionNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-10T19:30:54Z.
Measured on c6d9f9cb (main
4a747c48+ this commit), Linux, GCC, Release, SPIRV-Tools on.The regression does not pin the helper change. main's
verifyStructured(plaingraph.Dominates) plus onlyverifyLoopMergeDoesNotEnterNestedSelectionand itsmainhook: the test passes. The hand-built graph never getsBasicBlock::dominatorsfilled (only the structurizer's privatecomputeDominatorTreefills it), sograph.Dominatesis false for every pair,constructBlocksreturns no members for any header, and the old per-member checks never run on it. The shape itself is right: withStructuralDominatorsminus its two merge/continue edges (plain dominance, actually computed) the same graph fails withblock 3 of the selection at block 2 branches to block 4 outside the construct.A regression that pins (measured: passes with this PR's helper, fails on main's with
block 6 of the selection at block 2 branches to block 7 outside the construct, block 6 being the loop's merge): build the unstructured #2960 input{{1, 5}, {2, 3}, {5}, {5, 4}, {1}, {}}the waymakeGraphin tests/Structurizer.cpp does (ids, program counters, instruction ranges,SccNonZeroconditions, predecessors), runStructurizer{}.Structurize(graph), thenverifyStructured. That also keeps the regression on real structurizer output, where #2960 was found.End to end (harness from #2762, 903-shader sample incl. 199 invalid-SPIR-V outputs, main structurizer): the #2960 shader goes VALID_BUT_VERIFY_FAILED -> DONE; 12 of the sample's helper rejections of validator-accepted outputs (all
... outside the construct) become DONE; nothing the old helper accepted is rejected now; DONE/STRUCTURIZE/INVALID counts unchanged. With AlxcBTW#24 (0b56b7ad) as the structurizer: 17 -> DONE, the shapes I listed on #2642 among them, 0 new rejections. Side effect: 44 of the 199 invalid outputs (the #2762 class: 41branches to the selection construct, but not to the selection header, 3Selection must be structured) that the old helper flagged through the same plain-dominance artifact are no longer flagged, soverifyStructurednow flags 0/199 of them; only the validator catches that class, andverifyRequest(recorded requests) does not run it.Merges: clean with #2471 (470f51ce) and #2941 (
54b30588); the mergedControlFlow.cppcompiles in both cases.AI-assisted: yes (Claude Code Fable 5.1 xhigh)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-10T19:40:15Z.
Addressed in 03ed5aecb: the regression now builds the six-block #2960 input with populated block metadata, runs Structurizer, and verifies its eight-block output. It passes with the structural helper; substituting plain graph.Dominates reproduces the expected block 6 -> 7 failure. Updated the PR description and reran the focused CTest and conventions check.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-10T20:50:58Z.
I rebased both commits onto current
mainand rechecked the regression on Linux (GCC 12.2, Release).agc_shader_control_flowpasses with the structural-dominator helper. As a negative control, I temporarily replaced its dominator queries with the oldgraph.Dominatescalls; the test then fails with the reportedblock 6 ... branches to block 7 outside the constructdiagnostic. I restored the structural helper, rebuilt the target, and confirmed the focused test passes again. Conventions andgit diff --checkalso pass on the rebased branch.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T23:42:11Z.
Checked on the PR merged onto current main:
agc_shader_control_flowpasses (344/344 in the libSceAgcDriver scope). As a negative control, dropping the merge/continue edges fromStructuralDominatorsmakes the new #2960 regression fail. The helper now follows SPIR-V structural dominance and the regression runs the realStructurizer, which addresses the earlier review. Merging.