Shaders: validate far-jump arithmetic and control-flow entries #2684

Open
XeNS1 wants to merge 2 commits from upstream-pr/2686 into main
XeNS1 commented 2026-11-25 18:12:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by XeNS1 on 2026-11-25T18:12:46Z.


gfx10::far_jump followed a target derived from the low-word literal even when the high-word carry was missing, mismatched, or clobbered. A physical getpc / arithmetic / setpc sequence also does not prove a constant target when another branch enters after getpc: the bypassing path can carry a different register pair. Decode and IR previously recomputed this decision from different predecessor sets, which could produce an IR jump to code that was never decoded.

Validate the complete local getpc / low arithmetic / matching high carry / setpc chain, including both registers and both halves of the signed offset. Wide host arithmetic handles subtraction of i64::MIN. Within the existing four-instruction lookback, only NOPs, s_waitcnt and s_waitcnt_depctr may separate the operations.

Track discovered branch and jump destinations and leave the setpc indirect if any entry bypasses part of its setup. A later path can invalidate a chain already followed: in that case decode restarts with the additional entries retained, removing speculative code and its errors. Errors are deferred until pending paths have been explored, so an invalid speculative target cannot hide the path that invalidates it. The entry set only grows, and every retry blocks at least one newly invalidated chain. IR consumes the final decoded flow decisions rather than resolving the jump a second time. Entering at getpc remains valid; unreachable data is not scanned for apparent branches. This is conservative local recognition, not general constant propagation.

Eleven new synthetic tests cover arithmetic/carry validation, register and SCC clobbers, signed 64-bit offsets, scheduling controls, entries at low/high/setpc, both traversal orders, late ordinary and resolved-far entries, valid/invalid/out-of-range speculative targets, and flow decisions whose invalidating branch disappears on retry. The CFG negative cases check the indirect IR exit in both wave sizes. The original arithmetic regressions failed 3 tests against main; the CFG regressions failed 5 tests against the first PR revision. All 36 decoder/SP3/IR tests now pass.

Validation on Linux x86-64 / Rust 1.100.0:

  • An isolated Cargo harness imports the actual gfx10 and ir modules and the unchanged ShaderError enum, without behavior stubs. All 36 unit tests and strict all-target Clippy pass.
  • cargo check -p victory-shader --all-features --locked --offline passes. Changed code is formatted; repository asset policy (184 files), staged policy (2 files), and diff checks pass.
  • Full shader tests remain blocked locally by six pre-existing non-Windows references to emit::validator in lower.rs. Full-library strict Clippy on Rust 1.100 also hits the unchanged needless_range_loop at lower.rs:1061. Full Windows CI on pinned Rust 1.98.1 passes both workspace Clippy configurations and workspace tests on the updated head (run).

Semantics checked against AMD RDNA2 ISA, sections 12.1/12.3 and the LLVM 21.1 far-branch sequence. The decoder/control API changes here overlap #2012's lookup work and will need integration if both land. No GPU or game files used; all instruction fixtures are handwritten from the public ISA. No measured in-game impact claimed. AI-assisted: OpenAI Codex.

Coordination claim.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5496678863 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2686). Originally posted by [XeNS1](https://github.com/XeNS1) on 2026-11-25T18:12:46Z. --- `gfx10::far_jump` followed a target derived from the low-word literal even when the high-word carry was missing, mismatched, or clobbered. A physical getpc / arithmetic / setpc sequence also does not prove a constant target when another branch enters after getpc: the bypassing path can carry a different register pair. Decode and IR previously recomputed this decision from different predecessor sets, which could produce an IR jump to code that was never decoded. Validate the complete local getpc / low arithmetic / matching high carry / setpc chain, including both registers and both halves of the signed offset. Wide host arithmetic handles subtraction of i64::MIN. Within the existing four-instruction lookback, only NOPs, s_waitcnt and s_waitcnt_depctr may separate the operations. Track discovered branch and jump destinations and leave the setpc indirect if any entry bypasses part of its setup. A later path can invalidate a chain already followed: in that case decode restarts with the additional entries retained, removing speculative code and its errors. Errors are deferred until pending paths have been explored, so an invalid speculative target cannot hide the path that invalidates it. The entry set only grows, and every retry blocks at least one newly invalidated chain. IR consumes the final decoded flow decisions rather than resolving the jump a second time. Entering at getpc remains valid; unreachable data is not scanned for apparent branches. This is conservative local recognition, not general constant propagation. Eleven new synthetic tests cover arithmetic/carry validation, register and SCC clobbers, signed 64-bit offsets, scheduling controls, entries at low/high/setpc, both traversal orders, late ordinary and resolved-far entries, valid/invalid/out-of-range speculative targets, and flow decisions whose invalidating branch disappears on retry. The CFG negative cases check the indirect IR exit in both wave sizes. The original arithmetic regressions failed 3 tests against main; the CFG regressions failed 5 tests against the first PR revision. All 36 decoder/SP3/IR tests now pass. Validation on Linux x86-64 / Rust 1.100.0: - An isolated Cargo harness imports the actual gfx10 and ir modules and the unchanged ShaderError enum, without behavior stubs. All 36 unit tests and strict all-target Clippy pass. - `cargo check -p victory-shader --all-features --locked --offline` passes. Changed code is formatted; repository asset policy (184 files), staged policy (2 files), and diff checks pass. - Full shader tests remain blocked locally by six pre-existing non-Windows references to emit::validator in lower.rs. Full-library strict Clippy on Rust 1.100 also hits the unchanged needless_range_loop at lower.rs:1061. Full Windows CI on pinned Rust 1.98.1 passes both workspace Clippy configurations and workspace tests on the updated head ([run](https://github.com/Marvisak/VIctory/actions/runs/45679809099)). Semantics checked against [AMD RDNA2 ISA, sections 12.1/12.3](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content) and the [LLVM 21.1 far-branch sequence](https://github.com/llvm/llvm-project/blob/llvmorg-21.1.0/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp#L2760). The decoder/control API changes here overlap #2012's lookup work and will need integration if both land. No GPU or game files used; all instruction fixtures are handwritten from the public ISA. No measured in-game impact claimed. AI-assisted: OpenAI Codex. [Coordination claim](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7170421542).
DrDarkDK commented 2026-11-25 19:05:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T18:59:51Z.

Review: APPROVED


No description provided.

<!-- greyfinch-sync:Marvisak/VIctory:review:6063312660 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2686#pullrequestreview-6063312660). Originally posted by [DrDarkDK](https://github.com/DrDarkDK) on 2026-11-25T18:59:51Z. **Review:** APPROVED --- _No description provided._
DrDarkDK commented 2026-11-25 19:06:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T18:15:56Z.


A branch can reach s_setpc_b64 without executing the address setup the lookback validates. For example, a conditional branch can target setpc directly while fallthrough executes getpc, the low-word operation, and the carry. The lookback resolves one fixed target for both paths, even though the taken branch can arrive with a different address pair.

Could we add that control-flow case and leave the jump indirect when a branch can enter after getpc? Both the decoder and IR builder call control, so the test should check that they agree.

Static review only.

AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7170671394 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2686#issuecomment-7170671394). Originally posted by [DrDarkDK](https://github.com/DrDarkDK) on 2026-11-25T18:15:56Z. --- A branch can reach `s_setpc_b64` without executing the address setup the lookback validates. For example, a conditional branch can target `setpc` directly while fallthrough executes `getpc`, the low-word operation, and the carry. The lookback resolves one fixed target for both paths, even though the taken branch can arrive with a different address pair. Could we add that control-flow case and leave the jump indirect when a branch can enter after `getpc`? Both the decoder and IR builder call `control`, so the test should check that they agree. Static review only. *AI-assisted with Codex.*
kotekompotek commented 2026-11-25 19:06:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T18:38:13Z.


The recognizer is now honest: requiring the matching carry op (addc for add, subb for sub), checking both registers of the pair, and whitelisting only nop/waitcnt as separators closes both holes - a stale getpc+literal pairing and the +/-4GiB-vs-+20 high-word ambiguity. Combining the halves before negating (i128) also fixes the i64::MIN subtraction edge. Test matrix covers every failure mode I can think of, including SCC clobbers and register clobbers at each position in the chain.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171183469 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2686#issuecomment-7171183469). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T18:38:13Z. --- The recognizer is now honest: requiring the matching carry op (addc for add, subb for sub), checking both registers of the pair, and whitelisting only nop/waitcnt as separators closes both holes - a stale getpc+literal pairing and the +/-4GiB-vs-+20 high-word ambiguity. Combining the halves before negating (i128) also fixes the i64::MIN subtraction edge. Test matrix covers every failure mode I can think of, including SCC clobbers and register clobbers at each position in the chain.
fuzeofficlal commented 2026-11-25 19:06:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T18:40:29Z.


Independent Windows 11 verification and code review of 38b757ec (on 13f91ca):

Verification (rustc 1.98.1 MSVC)

  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings and --features host: 0 warnings.
  • gfx10: 21 passed, 0 failed (all 5 new far-jump tests pass).
  • ir::tests (9 passed), structure::tests (11 passed, 1 ignored), emit::flow_tests (1 passed).

Code Review Notes

  • The high-word pair validation (s_getpc_b64 -> s_add_u32/s_sub_u32 -> matching s_addc_u32/s_subb_u32 -> s_setpc_b64), GFX10 inline constant decoding (128..=192, 193..=208, 0xFF), i128 negation safety, and strict s_nop/s_waitcnt/s_waitcnt_depctr clobber rejection all look solid.
  • Confirming & expanding the CFG entry-point issue: because far_jump walks backward by byte offset through before(at) without checking whether a branch targets the interior of the chain or s_setpc_b64 directly, there is also a decode vs ir::build_bounded mismatch:
    • Consider 0x00: s_cbranch_scc1 getpc; 0x04: s_branch setpc. When decode() follows 0x04 to setpc first, found does not yet contain getpc..addc, so far_jump returns Indirect (Flow::Stop) and never decodes target.
    • pending then decodes getpc..addc into found.
    • Later, ir::build_bounded runs gfx10::control over the completed list, now sees getpc..addc immediately before setpc, classifies it as Flow::Jump(target), and fails block_at(target) (jump into a block) because target was never decoded.
    • Ensuring interior instructions / s_setpc_b64 are not branch targets (or handling the chain consistently across decode and ir::build_bounded) avoids both false-positive static jumps and this decode/IR divergence.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7171236146 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2686#issuecomment-7171236146). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T18:40:29Z. --- Independent Windows 11 verification and code review of `38b757ec` (on `13f91ca`): ### Verification (`rustc 1.98.1` MSVC) - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` and `--features host`: **0 warnings**. - `gfx10`: **21 passed, 0 failed** (all 5 new far-jump tests pass). - `ir::tests` (**9 passed**), `structure::tests` (**11 passed, 1 ignored**), `emit::flow_tests` (**1 passed**). ### Code Review Notes - The high-word pair validation (`s_getpc_b64` -> `s_add_u32`/`s_sub_u32` -> matching `s_addc_u32`/`s_subb_u32` -> `s_setpc_b64`), GFX10 inline constant decoding (`128..=192`, `193..=208`, `0xFF`), `i128` negation safety, and strict `s_nop`/`s_waitcnt`/`s_waitcnt_depctr` clobber rejection all look solid. - **Confirming & expanding the CFG entry-point issue:** because `far_jump` walks backward by byte offset through `before(at)` without checking whether a branch targets the interior of the chain or `s_setpc_b64` directly, there is also a `decode` vs `ir::build_bounded` mismatch: - Consider `0x00: s_cbranch_scc1 getpc; 0x04: s_branch setpc`. When `decode()` follows `0x04` to `setpc` first, `found` does not yet contain `getpc..addc`, so `far_jump` returns `Indirect` (`Flow::Stop`) and never decodes `target`. - `pending` then decodes `getpc..addc` into `found`. - Later, `ir::build_bounded` runs `gfx10::control` over the completed `list`, now sees `getpc..addc` immediately before `setpc`, classifies it as `Flow::Jump(target)`, and fails `block_at(target)` (`jump into a block`) because `target` was never decoded. - Ensuring interior instructions / `s_setpc_b64` are not branch targets (or handling the chain consistently across `decode` and `ir::build_bounded`) avoids both false-positive static jumps and this decode/IR divergence.
XeNS1 commented 2026-11-25 19:06:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by XeNS1 on 2026-11-25T18:57:33Z.


Addressed the CFG-entry and traversal-order findings in 6dbac145d9. Thanks @DrDarkDK and @fuzeofficlal for the concrete cases and the Windows verification of the first revision.

The decoder now records branch/jump destinations and rejects a setup with an entry in (getpc, setpc]. This includes destinations discovered later on another path, including resolved far jumps. If such an entry invalidates a chain already followed, decode restarts and discards speculative instructions and errors. Entries are retained across retries so removing the invalidating path cannot make the same chain oscillate between direct and indirect. Errors from speculative targets are deferred until pending paths have been visited.

IR uses the final decoded flow decisions instead of repeating the physical lookback on the final sorted instruction list. This covers the cbranch getpc; branch setpc ordering and the case where the branch invalidating a chain is itself removed during retry.

Six additional synthetic tests cover low/high/setpc entries, both visitation orders, late direct/far entries, valid/invalid/out-of-range speculative targets, and retained indirect decisions. A positive control still resolves a branch to getpc and ignores an unreachable data word resembling a branch. The CFG negative cases also check indirect IR exits for wave32 and wave64. With these tests, the previous PR revision had 31 pass / 5 fail; the updated code has 36 pass / 0 fail. Strict harness Clippy, all-features shader library check, repository/staged asset policy and diff checks pass locally. Fixtures are handwritten public-ISA instructions; no game data or game execution was used.

Windows CI on this exact head: passed both workspace Clippy configurations and the workspace tests (run).

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171632253 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2686#issuecomment-7171632253). Originally posted by [XeNS1](https://github.com/XeNS1) on 2026-11-25T18:57:33Z. --- Addressed the CFG-entry and traversal-order findings in 6dbac145d97a88ac3315353625b070d5a2b04f59. Thanks @DrDarkDK and @fuzeofficlal for the concrete cases and the Windows verification of the first revision. The decoder now records branch/jump destinations and rejects a setup with an entry in `(getpc, setpc]`. This includes destinations discovered later on another path, including resolved far jumps. If such an entry invalidates a chain already followed, decode restarts and discards speculative instructions and errors. Entries are retained across retries so removing the invalidating path cannot make the same chain oscillate between direct and indirect. Errors from speculative targets are deferred until pending paths have been visited. IR uses the final decoded flow decisions instead of repeating the physical lookback on the final sorted instruction list. This covers the `cbranch getpc; branch setpc` ordering and the case where the branch invalidating a chain is itself removed during retry. Six additional synthetic tests cover low/high/setpc entries, both visitation orders, late direct/far entries, valid/invalid/out-of-range speculative targets, and retained indirect decisions. A positive control still resolves a branch to getpc and ignores an unreachable data word resembling a branch. The CFG negative cases also check indirect IR exits for wave32 and wave64. With these tests, the previous PR revision had 31 pass / 5 fail; the updated code has 36 pass / 0 fail. Strict harness Clippy, all-features shader library check, repository/staged asset policy and diff checks pass locally. Fixtures are handwritten public-ISA instructions; no game data or game execution was used. Windows CI on this exact head: passed both workspace Clippy configurations and the workspace tests ([run](https://github.com/Marvisak/VIctory/actions/runs/45679809099)). AI-assisted with OpenAI Codex.
pablogonz12 commented 2026-11-25 20:06:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by pablogonz12 on 2026-11-25T19:41:16Z.


AMD/RADV offline check of the head commit (no game run).

  • Hardware / stack: RX 9070 XT, Mesa 26.3.1 RADV, GE-Proton11-14; base = origin/main 13f91caee.
  • Method: the 751-program world-shader dump, translated by each tree's own victory-shader --example retranslate, then dxil-spirv (master), spirv-val --target-env vulkan1.3, and a real vkCreateCompute/GraphicsPipelines on RADV (vkpipe, one process per program, so a driver crash or hang is recorded per program rather than stopping the batch).
  • Offline only: pipelines are created, never bound or drawn, so wrong pixels and ISA-level miscompiles are out of reach here.
    Result, base 13f91caee vs head 6dbac145d: both translate 749 / 751 (the same 2 refused in both: a lane mask read as data is not supported). 0 of the 751 programs' DXIL bytes change, no pipeline result or time differs.

None of these programs takes a far jump, so the validation this PR adds is not reached by the dump: the new tests are the evidence, and victory-shader's test target does not build on Linux here (Windows validator module). No objection from this side.

Not tested in a game run; not tested on NVIDIA.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7172634914 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2686#issuecomment-7172634914). Originally posted by [pablogonz12](https://github.com/pablogonz12) on 2026-11-25T19:41:16Z. --- AMD/RADV offline check of the head commit (no game run). - Hardware / stack: RX 9070 XT, Mesa 26.3.1 RADV, GE-Proton11-14; base = `origin/main` 13f91caee. - Method: the 751-program world-shader dump, translated by each tree's own `victory-shader --example retranslate`, then dxil-spirv (master), `spirv-val --target-env vulkan1.3`, and a real `vkCreateCompute/GraphicsPipelines` on RADV (`vkpipe`, one process per program, so a driver crash or hang is recorded per program rather than stopping the batch). - Offline only: pipelines are created, never bound or drawn, so wrong pixels and ISA-level miscompiles are out of reach here. **Result, base 13f91caee vs head 6dbac145d:** both translate **749 / 751** (the same 2 refused in both: `a lane mask read as data is not supported`). **0 of the 751** programs' DXIL bytes change, no pipeline result or time differs. None of these programs takes a far jump, so the validation this PR adds is not reached by the dump: the new tests are the evidence, and `victory-shader`'s test target does not build on Linux here (Windows validator module). No objection from this side. Not tested in a game run; not tested on NVIDIA.
fuzeofficlal commented 2026-11-25 20:06:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T19:51:06Z.


Re-verified 6dbac14 on Windows 11 (rustc 1.98.1 MSVC, 13f91ca):

Verification

  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings and --features host: 0 warnings.
  • cargo xtask policy: 184 files ok.
  • gfx10: 27 passed, 0 failed (all 6 new CFG entry / traversal-order / far-jump recheck tests pass), ir:: 9 passed, structure 11 passed (1 ignored), emit::flow_tests 1 passed.

Review Confirmation

  • Both the interior/s_setpc_b64 entry-point issue and the decode vs ir::build_bounded traversal-order divergence are cleanly resolved: decode_with_flows's monotonic entries: BTreeSet<usize> retry loop (allowing entries to start while rejecting (start + 1..=end)), deferred speculative errors, and having ir::build_bounded consume the resolved flows directly close the loop completely. Looks ready to merge!
<!-- greyfinch-sync:Marvisak/VIctory:comment:7172848730 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2686#issuecomment-7172848730). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T19:51:06Z. --- Re-verified `6dbac14` on Windows 11 (`rustc 1.98.1` MSVC, `13f91ca`): ### Verification - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` and `--features host`: **0 warnings**. - `cargo xtask policy`: **184 files ok**. - `gfx10`: **27 passed, 0 failed** (all 6 new CFG entry / traversal-order / far-jump recheck tests pass), `ir::` **9 passed**, `structure` **11 passed (1 ignored)**, `emit::flow_tests` **1 passed**. ### Review Confirmation - Both the interior/`s_setpc_b64` entry-point issue and the `decode` vs `ir::build_bounded` traversal-order divergence are cleanly resolved: `decode_with_flows`'s monotonic `entries: BTreeSet<usize>` retry loop (allowing entries to `start` while rejecting `(start + 1..=end)`), deferred speculative errors, and having `ir::build_bounded` consume the resolved `flows` directly close the loop completely. Looks ready to merge!
Marvisak commented 2026-11-25 23:06:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:19:10Z.


Automated triage for the maintainers.

Merge candidate (recommend a look). gfx10::far_jump now accepts a getpc / s_add_u32|s_sub_u32 / matching s_addc_u32|s_subb_u32 / setpc chain only when the registers and carry match and nothing but s_nop/s_waitcnt/s_waitcnt_depctr sits between the steps. It builds the offset from both words (i128, so -i64::MIN is safe). decode_with_flows leaves the setpc indirect when any branch enters after getpc, and ir::build_bounded now uses the decoder's final flow decisions instead of resolving the jump a second time. I read the retry loop: entries only grow, and a chain blocked by a known entry is never accepted again, so it terminates. Errors are held until the walk is final. The only other caller of the removed control was ir.rs. The change is more conservative than main (more jumps stay indirect), and the semantics are cited to the public RDNA2 ISA and LLVM's far-branch sequence. The two decode/IR divergence cases raised in review are covered by tests.

Heads-up: it conflicts with #2012 (decode by dword table) in crates/victory-shader/src/gfx10/mod.rs, so whichever lands second needs a rebase.

CI: check passing on this head.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176213774 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2686#issuecomment-7176213774). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:19:10Z. --- <!-- victory-triage v1 head=6dbac145d97a88ac3315353625b070d5a2b04f59 verdict=merge-candidate at=2026-11-25T22:21:00Z --> Automated triage for the maintainers. **Merge candidate (recommend a look).** `gfx10::far_jump` now accepts a getpc / `s_add_u32|s_sub_u32` / matching `s_addc_u32|s_subb_u32` / setpc chain only when the registers and carry match and nothing but `s_nop`/`s_waitcnt`/`s_waitcnt_depctr` sits between the steps. It builds the offset from both words (i128, so `-i64::MIN` is safe). `decode_with_flows` leaves the setpc indirect when any branch enters after getpc, and `ir::build_bounded` now uses the decoder's final flow decisions instead of resolving the jump a second time. I read the retry loop: entries only grow, and a chain blocked by a known entry is never accepted again, so it terminates. Errors are held until the walk is final. The only other caller of the removed `control` was `ir.rs`. The change is more conservative than main (more jumps stay indirect), and the semantics are cited to the public RDNA2 ISA and LLVM's far-branch sequence. The two decode/IR divergence cases raised in review are covered by tests. Heads-up: it conflicts with #2012 (decode by dword table) in `crates/victory-shader/src/gfx10/mod.rs`, so whichever lands second needs a rebase. CI: `check` passing on this head. --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-27 02:26:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T02:26:39Z.

Review: CHANGES_REQUESTED


Reviewed 6dbac145d97a88ac3315353625b070d5a2b04f59.

The i128 64-bit carry/borrow arithmetic (s_add_u32/s_addc_u32 and s_sub_u32/s_subb_u32), clobber rejection, and decode_with_flows entry-rechecking convergence loop look solid (cargo xtask policy, clippy --all-targets/--all-features, gfx10::tests 27/27, ir::tests 9/9, and rustfmt all pass cleanly).

One validation gap to address before merging:

  • Missing 4-byte alignment check on far_jump targets (crates/victory-shader/src/gfx10/mod.rs:272-275):
    • flow() preserves 4-byte alignment via 4 * i16, whereas far_jump() computes an arbitrary byte delta and only filters .filter(|&t| t < len) without .is_multiple_of(4).
    • If a far jump encodes an unaligned target (e.g. target = 22 past setpc + 4 = 20 in a 28-byte buffer), decode_with_flows decodes unaligned bytes across dword boundaries, and the overlap check w[0].offset + 4 * w[0].words.len() > w[1].offset (20 > 22 is false) does not catch it before handing the unaligned leader to ir::build_bounded. Conversely, an unaligned target inside start + 1..=end enters entries and turns a malformed jump into Flow::Stop instead of an ISA error.
    • Filtering .filter(|&t| t < len && t.is_multiple_of(4)) (plus a unit test covering an unaligned far-jump offset) closes this cleanly.
<!-- greyfinch-sync:Marvisak/VIctory:review:6082685963 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2686#pullrequestreview-6082685963). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-27T02:26:39Z. **Review:** CHANGES_REQUESTED --- Reviewed `6dbac145d97a88ac3315353625b070d5a2b04f59`. The `i128` 64-bit carry/borrow arithmetic (`s_add_u32`/`s_addc_u32` and `s_sub_u32`/`s_subb_u32`), clobber rejection, and `decode_with_flows` entry-rechecking convergence loop look solid (`cargo xtask policy`, `clippy --all-targets`/`--all-features`, `gfx10::tests` 27/27, `ir::tests` 9/9, and `rustfmt` all pass cleanly). One validation gap to address before merging: - **Missing 4-byte alignment check on `far_jump` targets (`crates/victory-shader/src/gfx10/mod.rs:272-275`)**: - `flow()` preserves 4-byte alignment via `4 * i16`, whereas `far_jump()` computes an arbitrary byte `delta` and only filters `.filter(|&t| t < len)` without `.is_multiple_of(4)`. - If a far jump encodes an unaligned target (e.g. `target = 22` past `setpc + 4 = 20` in a 28-byte buffer), `decode_with_flows` decodes unaligned bytes across dword boundaries, and the overlap check `w[0].offset + 4 * w[0].words.len() > w[1].offset` (`20 > 22` is false) does not catch it before handing the unaligned leader to `ir::build_bounded`. Conversely, an unaligned target inside `start + 1..=end` enters `entries` and turns a malformed jump into `Flow::Stop` instead of an ISA error. - Filtering `.filter(|&t| t < len && t.is_multiple_of(4))` (plus a unit test covering an unaligned far-jump offset) closes this cleanly.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2686:upstream-pr/2686'
git switch 'upstream-pr/2686'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2686'
git switch 'upstream-pr/2686'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2686'
git switch 'upstream-pr/2686'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2686'
git switch 'main'
git merge --squash 'upstream-pr/2686'
git switch 'main'
git merge --ff-only 'upstream-pr/2686'
git switch 'main'
git merge 'upstream-pr/2686'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!2684
No description provided.