shader: admit proven calculated far early-outs #2956

Manually merged
github merged 3 commits from github-bot/gh-2956 into gh-pr/2956/base 2026-11-27 04:23:57 +00:00 AGit
Owner

@⁠chadhyatt on GitHub · 2026-11-26 23:13 UTC · original
chadhyatt:backport/shader-far-early-out → main · +699 −13 · 5 files · 3 commits · merged 2026-11-27 04:20 UTC

AI-assisted backport patch from x2w-microlift.

Extend the gfx1013 pixel two-exit profile with a single proven forward calculated transfer onto a pure terminating continuation. Reuse the existing calculated-PC proof, require the fresh contiguous GETPC/ADD/ADDC/SETPC chain and reject observable continuation effects. The stand-alone pixel lowering remains unchanged.

Apple Silicon macOS, revision 2615baa8b2:

  • python3 -B tests/startup_gfx2hlsl_far_early_out_check.py: three authored variants, both selector outcomes and refusal controls passed. LLVM 15 extraction capability skipped locally.
  • python3 -B tests/startup_gfx2hlsl_far_early_out_check.py binary /opt/homebrew/opt/llvm/bin/llvm-mc: exact assembly roundtrip passed with LLVM 23.1.6.
  • python3 -B tests/startup_gfx2hlsl_calculated_target_check.py: passed.
  • python3 -B tests/docs_links_check.py: passed.
  • git diff --check: passed.

Windows and LLVM 15 extraction not run on this host; existing CI lanes retain their checks and add the new fixture.

**@⁠chadhyatt** on GitHub · 2026-11-26 23:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2956) `chadhyatt:backport/shader-far-early-out` → `main` · +699 −13 · 5 files · 3 commits · merged 2026-11-27 04:20 UTC AI-assisted backport patch from x2w-microlift. Extend the gfx1013 pixel two-exit profile with a single proven forward calculated transfer onto a pure terminating continuation. Reuse the existing calculated-PC proof, require the fresh contiguous GETPC/ADD/ADDC/SETPC chain and reject observable continuation effects. The stand-alone pixel lowering remains unchanged. Apple Silicon macOS, revision 2615baa8b2: - `python3 -B tests/startup_gfx2hlsl_far_early_out_check.py`: three authored variants, both selector outcomes and refusal controls passed. LLVM 15 extraction capability skipped locally. - `python3 -B tests/startup_gfx2hlsl_far_early_out_check.py binary /opt/homebrew/opt/llvm/bin/llvm-mc`: exact assembly roundtrip passed with LLVM 23.1.6. - `python3 -B tests/startup_gfx2hlsl_calculated_target_check.py`: passed. - `python3 -B tests/docs_links_check.py`: passed. - `git diff --check`: passed. Windows and LLVM 15 extraction not run on this host; existing CI lanes retain their checks and add the new fixture.
Bound the existing calculated target proof to a pure terminating continuation for the gfx1013 two-exit pixel profile. Add source-built controls, assembled-word comparison, and separate LLVM extraction evidence.
AI-assisted backport patch from x2w-microlift.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:30:40 +00:00
Author
Owner

@⁠thepatrickworld on GitHub · 2026-11-27 03:06 UTC · original

Independent Python-only audit of 2615baa8: the refusal matrix on the base, the extraction half the body left unrun, and nine clause mutants

Not a code change; measurements only. No GPU and no Windows here: gfx2hlsl, pixel_aot and the decoder are Python, and everything below runs before any HLSL is compiled.

Environment

  • Linux x86-64, Python 3.11.16, no D3D12 device, no libLLVM-15.
  • base 6ee878d8 (current main), head 2615baa8, separate worktrees; git status --porcelain --untracked-files=no empty in both, the base carrying the copied fixture below as the only untracked file.

Commands

git worktree add /tmp/base 6ee878d8 ; git worktree add /tmp/head 2615baa8
cd /tmp/head && python3 -B tests/startup_gfx2hlsl_far_early_out_check.py
cp head/tests/startup_gfx2hlsl_far_early_out_check.py /tmp/base/tests/
cd /tmp/base && python3 -B tests/startup_gfx2hlsl_far_early_out_check.py

The base already refuses 12 of the 15 negatives, and accepts 3

negative() raises at the first accepted program, so the fixture on the base reports one program, not the matrix. I replayed each negative as its own program against both trees:

  • refused with the message the fixture expects, by calculated_pc_proof (10): register-derived displacement, missing ADDC, wrong sign extension, signed low-word ADD, competing entry into the chain, pair clobbering, address escape, SCC escape, target off an instruction boundary, target outside the program — e.g. s_setpc_b64: unknown or ambiguous calculated target from s[20:21] at +0x48 for pair clobbering, identical on both trees.
  • refused by another site, with a different message (2): continuation buffer_store_dword and s_barrier hit the generic unsupported-instruction check on the base.
  • accepted by the base (3): stale scratch pair, continuation exp, continuation s_mov_b32 exec_lo, 0. Run alone, the head refuses all three (far early-out: the scratch pair s[20:21] is not fresh, far early-out: the continuation instruction …).

The startup half admits nothing new: it removes three admissions

For the two effectful continuations the base does not drop the instruction, it emits it. From Stage(...).body() on the base, with exp mrt0 v4, v4, v4, v4 done vm at the continuation:

if (pc == 3) {
    o.mrt0 = uint4(v4, v4, v4, v4);
    pc = 0xffffu;
}

with s_mov_b32 exec_lo, 0 at the continuation:

if (pc == 3) {
    exec = (0x00000000u) & 1;
    pc = 0xffffu;
}

and with the pre-written s21 of the stale-pair program the base writes s21 = 0x00000005u; in the entry block and still jumps statically to an empty terminating block — the pre-written pair changes nothing in its output, which is what the new clause refuses.

So no program gains an accepted emission on the Stage side; three lose theirs. For the five programs both trees accept (short branch, short calculated, far calculated, v_nop continuation, three s_endpgm) the emitted body is byte-identical: sha256[:16] of the stripped body is e422a90516e79788 for the four single-exit-continuation ones and 5d8d8a0eb35e5ea4 for the three-s_endpgm one, on both trees. The three variants share one dispatcher because the chain is elided and the jump lands in the same block.

What the extraction half adds, executed

pixel_aot on the base, same programs, same library, in the markers == 2 and llvm is not None branch of container_code:

  • short s_branch: span returned unchanged (80 bytes) — already accepted before this PR, it contains no s_getpc_b64;
  • short calculated (92 bytes, displacement 24) and far calculated (131168 bytes): ValueError: Unverified multi-exit control flow: s_getpc_b64.

The same is true of every two-exit program with a calculated transfer that I built (short calculated, far calculated, stale pair, export continuation, EXEC continuation) — all refused that way on the base — while short s_branch, which carries no s_getpc_b64, is returned unchanged there. So before this PR the extractor refuses a two-exit pixel program with a calculated transfer whatever its distance. On the head all three variants come back unchanged and the whole fixture passes with the extraction enabled (Far early-out: three variants, dispatcher oracle and refusal controls passed); each of the 15 negatives then refuses through the extractor as well as the Stage, with the same message on both (refused (…) instead of refused by the translator (…); extraction skipped). That is the capability this PR buys, and it is on the pixel_aot side.

Clause coverage: 2 of 9 clause mutants are killed

One textual mutation at a time in terminal_continuation_proof, the fixture run after each, file restored with git checkout -- and its sha256 checked back to the pre-mutant value:

killed by the fixture

  • the scratch-pair freshness clause (if False and {pair, pair + 1} & scalar_registers(asm)) → stale scratch pair: the startup translator accepted a refused program;
  • the effectful-continuation raise (at += _n; continue) → effectful continuation (an export): the startup translator accepted a refused program.

survive the fixture (rc=0, whole file green)

  • for off in chain[1:]: if off in branch_targets — disabled: green. Not exercised by the fixture, and the three interior entries I built are refused upstream by calculated_pc_proof on both trees: the fixture's own competing entry (targets the ADD), a branch to the ADDC (s_setpc_b64: missing matching low-word carry for calculated PC high-word addition at +0x40), a branch to the SETPC (s_setpc_b64: unknown or ambiguous calculated target from s[20:21] at +0x44). Redundancy is shown for those three entries only.
  • or extension != (-1 if displacement < 0 else 0) — disabled: green. The base refuses the fixture's wrong sign extension without this clause, and the same agreement test already exists in calculated_pc_proof.
  • len(transfers) != 1 or len(ends) != 2 → < 2: green, and a three-s_endpgm variant is accepted with an identical body by both trees, so the guard never decides on these programs.
  • if target != chain[0] + get_n + displacement — disabled: green; I could not build a program that reaches this test separately from the arithmetic calculated_pc_proof already did.
  • if target <= setpc — disabled: green, and I could not exercise it: the only backward targets I could build point back into the chain (the early export, the s_getpc_b64 itself) and are refused upstream as an ambiguous loop. Unpinned, with no measurement either way.
  • if asm != 's_endpgm' or at != ends[-1] — disabled: green, and this one is reachable (next section).
  • the trailing raise … leaves the decoded program before ending: I could not reach it; my attempt at a continuation that walks off the end is refused earlier (s_setpc_b64: target 0x20060 outside decoded program at +0x48).

One reachable clause has no case: the continuation must end at the last decoded s_endpgm

Take the fixture's own variant(CHAIN) rows, insert one s_nop 0 between EXP_B and the first s_endpgm, and re-encode the ADD to land on that NOP (d = 20, target 0x50, the first s_endpgm at 0x54, the last at 0x5c):

  • base: accepted, blocks [(branch, '!scc', 72) at 0, (jump, 80) at 48, (end,) at 80, (end,) at 88];
  • head: Unsupported: far early-out: the continuation ends at +0x54, not the program's final exit;
  • with the at != ends[-1] conjunct dropped, the head accepts that same program and the whole fixture stays green.

So this is the one clause that is reachable by the proof and unpinned by the fixture. A negative case in check_negatives — one inserted s_nop 0 and the ADD re-aimed, about ten lines next to rows_boundary — would pin it. Note that ends[-1] is the last decoded s_endpgm, not the end of the span; the extractor has its own exits[-1] + 4 == len(code) check, the Stage proof does not.

Small things in the fixture itself

Its usage line offers binary <llvm-mc> [llvm-objcopy] [libLLVM], but main() rejects anything but exactly two arguments, and resolve_libllvm's docstring mentions a decode mode this file does not have — so an LLVM library cannot be passed explicitly, and the extraction half runs only where resolve_libllvm() finds one of its four names.

Limits

  • No GPU, no Windows, no debug layer: nothing here says anything about the HLSL executing. The dispatcher oracle is an interpreter of the emitted text, over two selector values and four (x, y) pairs on uniform-lane programs.
  • The extraction half ran against libLLVM-21, not libLLVM-15: this host has no 15, the fixture as shipped prints extraction skipped (no LLVM 15 library found), and I drove its own extract() with the 21 library. pixel_aot uses the LLVM C API to enumerate the instruction inventory; the accept/refuse decision then comes from the repository's decoder and this proof. A run with LLVM 15 proper would be worth having.
  • "Reachable" means reachable by the proof; none of these programs is a shader produced by hardware, they are built from the fixture's own rows and encodings.
  • terminal_continuation_proof is called for every stage kind (ps, vs, cs, ms), not only the pixel two-exit profile the commit describes; and when the Stage is built with a refusals list the reason is collected and the translation continues, so the check is diagnostic on that path and refuses only the strict construction.
  • The CI pixel-binary entry (binary llvm-mc-15) only reassembles the three sources and never reaches the Stage or pixel_aot; the python-linux job does run this fixture without arguments, where the extraction is conditional on a libLLVM-15 that the job does not install, and whether the image carries one is not provable from the repository.

AI-assisted.

**@⁠thepatrickworld** on GitHub · 2026-11-27 03:06 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2956#issuecomment-7208712287) **Independent Python-only audit of `2615baa8`: the refusal matrix on the base, the extraction half the body left unrun, and nine clause mutants** Not a code change; measurements only. No GPU and no Windows here: `gfx2hlsl`, `pixel_aot` and the decoder are Python, and everything below runs before any HLSL is compiled. ### Environment - Linux x86-64, Python 3.11.16, no D3D12 device, no `libLLVM-15`. - base `6ee878d8` (current `main`), head `2615baa8`, separate worktrees; `git status --porcelain --untracked-files=no` empty in both, the base carrying the copied fixture below as the only untracked file. ### Commands ``` git worktree add /tmp/base 6ee878d8 ; git worktree add /tmp/head 2615baa8 cd /tmp/head && python3 -B tests/startup_gfx2hlsl_far_early_out_check.py cp head/tests/startup_gfx2hlsl_far_early_out_check.py /tmp/base/tests/ cd /tmp/base && python3 -B tests/startup_gfx2hlsl_far_early_out_check.py ``` ### The base already refuses 12 of the 15 negatives, and accepts 3 `negative()` raises at the first accepted program, so the fixture on the base reports one program, not the matrix. I replayed each negative as its own program against both trees: - refused with the message the fixture expects, by `calculated_pc_proof` (10): register-derived displacement, missing ADDC, wrong sign extension, signed low-word ADD, competing entry into the chain, pair clobbering, address escape, SCC escape, target off an instruction boundary, target outside the program — e.g. `s_setpc_b64: unknown or ambiguous calculated target from s[20:21] at +0x48` for pair clobbering, identical on both trees. - refused by another site, with a different message (2): continuation `buffer_store_dword` and `s_barrier` hit the generic unsupported-instruction check on the base. - **accepted by the base (3)**: stale scratch pair, continuation `exp`, continuation `s_mov_b32 exec_lo, 0`. Run alone, the head refuses all three (`far early-out: the scratch pair s[20:21] is not fresh`, `far early-out: the continuation instruction …`). ### The startup half admits nothing new: it removes three admissions For the two effectful continuations the base does not drop the instruction, it emits it. From `Stage(...).body()` on the base, with `exp mrt0 v4, v4, v4, v4 done vm` at the continuation: ``` if (pc == 3) { o.mrt0 = uint4(v4, v4, v4, v4); pc = 0xffffu; } ``` with `s_mov_b32 exec_lo, 0` at the continuation: ``` if (pc == 3) { exec = (0x00000000u) & 1; pc = 0xffffu; } ``` and with the pre-written `s21` of the stale-pair program the base writes `s21 = 0x00000005u;` in the entry block and still jumps statically to an empty terminating block — the pre-written pair changes nothing in its output, which is what the new clause refuses. So no program gains an accepted emission on the Stage side; three lose theirs. For the five programs both trees accept (short branch, short calculated, far calculated, `v_nop` continuation, three `s_endpgm`) the emitted body is byte-identical: `sha256[:16]` of the stripped body is `e422a90516e79788` for the four single-exit-continuation ones and `5d8d8a0eb35e5ea4` for the three-`s_endpgm` one, on both trees. The three variants share one dispatcher because the chain is elided and the jump lands in the same block. ### What the extraction half adds, executed `pixel_aot` on the base, same programs, same library, in the `markers == 2` and `llvm is not None` branch of `container_code`: - `short s_branch`: span returned unchanged (80 bytes) — already accepted before this PR, it contains no `s_getpc_b64`; - `short calculated` (92 bytes, displacement 24) and `far calculated` (131168 bytes): `ValueError: Unverified multi-exit control flow: s_getpc_b64`. The same is true of every two-exit program with a calculated transfer that I built (short calculated, far calculated, stale pair, export continuation, EXEC continuation) — all refused that way on the base — while `short s_branch`, which carries no `s_getpc_b64`, is returned unchanged there. So before this PR the extractor refuses a two-exit pixel program with a calculated transfer whatever its distance. On the head all three variants come back unchanged and the whole fixture passes with the extraction enabled (`Far early-out: three variants, dispatcher oracle and refusal controls passed`); each of the 15 negatives then refuses through the extractor as well as the Stage, with the same message on both (`refused (…)` instead of `refused by the translator (…); extraction skipped`). That is the capability this PR buys, and it is on the `pixel_aot` side. ### Clause coverage: 2 of 9 clause mutants are killed One textual mutation at a time in `terminal_continuation_proof`, the fixture run after each, file restored with `git checkout --` and its sha256 checked back to the pre-mutant value: killed by the fixture - the scratch-pair freshness clause (`if False and {pair, pair + 1} & scalar_registers(asm)`) → `stale scratch pair: the startup translator accepted a refused program`; - the effectful-continuation raise (`at += _n; continue`) → `effectful continuation (an export): the startup translator accepted a refused program`. survive the fixture (rc=0, whole file green) - `for off in chain[1:]: if off in branch_targets` — disabled: green. Not exercised by the fixture, and the three interior entries I built are refused upstream by `calculated_pc_proof` on both trees: the fixture's own competing entry (targets the ADD), a branch to the ADDC (`s_setpc_b64: missing matching low-word carry for calculated PC high-word addition at +0x40`), a branch to the SETPC (`s_setpc_b64: unknown or ambiguous calculated target from s[20:21] at +0x44`). Redundancy is shown for those three entries only. - `or extension != (-1 if displacement < 0 else 0)` — disabled: green. The base refuses the fixture's wrong sign extension without this clause, and the same agreement test already exists in `calculated_pc_proof`. - `len(transfers) != 1 or len(ends) != 2` → `< 2`: green, and a three-`s_endpgm` variant is accepted with an identical body by both trees, so the guard never decides on these programs. - `if target != chain[0] + get_n + displacement` — disabled: green; I could not build a program that reaches this test separately from the arithmetic `calculated_pc_proof` already did. - `if target <= setpc` — disabled: green, and I could not exercise it: the only backward targets I could build point back into the chain (the early export, the `s_getpc_b64` itself) and are refused upstream as an ambiguous loop. Unpinned, with no measurement either way. - `if asm != 's_endpgm' or at != ends[-1]` — disabled: green, and this one is reachable (next section). - the trailing `raise … leaves the decoded program before ending`: I could not reach it; my attempt at a continuation that walks off the end is refused earlier (`s_setpc_b64: target 0x20060 outside decoded program at +0x48`). ### One reachable clause has no case: the continuation must end at the last decoded `s_endpgm` Take the fixture's own `variant(CHAIN)` rows, insert one `s_nop 0` between `EXP_B` and the first `s_endpgm`, and re-encode the ADD to land on that NOP (`d = 20`, target `0x50`, the first `s_endpgm` at `0x54`, the last at `0x5c`): - base: accepted, blocks `[(branch, '!scc', 72) at 0, (jump, 80) at 48, (end,) at 80, (end,) at 88]`; - head: `Unsupported: far early-out: the continuation ends at +0x54, not the program's final exit`; - with the `at != ends[-1]` conjunct dropped, the head accepts that same program and the whole fixture stays green. So this is the one clause that is reachable by the proof and unpinned by the fixture. A negative case in `check_negatives` — one inserted `s_nop 0` and the ADD re-aimed, about ten lines next to `rows_boundary` — would pin it. Note that `ends[-1]` is the last decoded `s_endpgm`, not the end of the span; the extractor has its own `exits[-1] + 4 == len(code)` check, the Stage proof does not. ### Small things in the fixture itself Its usage line offers `binary <llvm-mc> [llvm-objcopy] [libLLVM]`, but `main()` rejects anything but exactly two arguments, and `resolve_libllvm`'s docstring mentions a `decode` mode this file does not have — so an LLVM library cannot be passed explicitly, and the extraction half runs only where `resolve_libllvm()` finds one of its four names. ### Limits - No GPU, no Windows, no debug layer: nothing here says anything about the HLSL executing. The dispatcher oracle is an interpreter of the emitted text, over two selector values and four `(x, y)` pairs on uniform-lane programs. - The extraction half ran against `libLLVM-21`, not `libLLVM-15`: this host has no 15, the fixture as shipped prints `extraction skipped (no LLVM 15 library found)`, and I drove its own `extract()` with the 21 library. `pixel_aot` uses the LLVM C API to enumerate the instruction inventory; the accept/refuse decision then comes from the repository's decoder and this proof. A run with LLVM 15 proper would be worth having. - "Reachable" means reachable by the proof; none of these programs is a shader produced by hardware, they are built from the fixture's own rows and encodings. - `terminal_continuation_proof` is called for every stage kind (`ps`, `vs`, `cs`, `ms`), not only the pixel two-exit profile the commit describes; and when the Stage is built with a `refusals` list the reason is collected and the translation continues, so the check is diagnostic on that path and refuses only the strict construction. - The CI `pixel-binary` entry (`binary llvm-mc-15`) only reassembles the three sources and never reaches the Stage or `pixel_aot`; the `python-linux` job does run this fixture without arguments, where the extraction is conditional on a `libLLVM-15` that the job does not install, and whether the image carries one is not provable from the repository. _AI-assisted._
Author
Owner

@⁠chadhyatt on GitHub · 2026-11-27 03:08 UTC · original

@⁠thepatrickworld Thank you for the exact base/head extraction comparison and clause controls. I will add the reachable earlier-continuation termination negative and correct explicit LLVM library selection in the fixture. I agree that the startup-side changes tighten admission, while the new capability is extraction. No GPU execution claim.

**@⁠chadhyatt** on GitHub · 2026-11-27 03:08 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2956#issuecomment-7208737381) @⁠thepatrickworld Thank you for the exact base/head extraction comparison and clause controls. I will add the reachable earlier-continuation termination negative and correct explicit LLVM library selection in the fixture. I agree that the startup-side changes tighten admission, while the new capability is extraction. No GPU execution claim.
AI-assisted backport patch from x2w-microlift.
The authored early termination negative is refused by both strict Stage construction and the LLVM 15 extraction path; binary controls reassemble exactly.
Author
Owner

@⁠chadhyatt on GitHub · 2026-11-27 03:24 UTC · original

@⁠thepatrickworld Updated dfd691825e. The reachable continuation ending before the final exit is now a negative control; controls <libLLVM> explicitly selects the extraction library for all positive and negative checks.

Verified on Apple Silicon with LLVM 15.0.7:
python3 -B tests/startup_gfx2hlsl_far_early_out_check.py controls /opt/homebrew/opt/llvm@15/lib/libLLVM-15.dylib - three positive exact extractions and all 16 refusal cases, including the new earlier termination, passed through the Stage and extractor.
python3 -B tests/startup_gfx2hlsl_far_early_out_check.py binary /opt/homebrew/opt/llvm@15/bin/llvm-mc /opt/homebrew/opt/llvm@15/lib/libLLVM-15.dylib - all three variants reassembled and extracted byte-identically. Fixture-only amendment; no GPU claim.

AI-assisted backport patch from x2w-microlift.

**@⁠chadhyatt** on GitHub · 2026-11-27 03:24 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2956#issuecomment-7208969037) @⁠thepatrickworld Updated dfd691825ef96a1ac7eec35aa361472c402f8d34. The reachable continuation ending before the final exit is now a negative control; `controls <libLLVM>` explicitly selects the extraction library for all positive and negative checks. Verified on Apple Silicon with LLVM 15.0.7: `python3 -B tests/startup_gfx2hlsl_far_early_out_check.py controls /opt/homebrew/opt/llvm@15/lib/libLLVM-15.dylib` - three positive exact extractions and all 16 refusal cases, including the new earlier termination, passed through the Stage and extractor. `python3 -B tests/startup_gfx2hlsl_far_early_out_check.py binary /opt/homebrew/opt/llvm@15/bin/llvm-mc /opt/homebrew/opt/llvm@15/lib/libLLVM-15.dylib` - all three variants reassembled and extracted byte-identically. Fixture-only amendment; no GPU claim. AI-assisted backport patch from x2w-microlift.
Author
Owner

@⁠thepatrickworld on GitHub · 2026-11-27 03:57 UTC · original

Follow-up on dfd691825e: the case you added does pin the distance clause, and the no-argument mode now ignores the library it finds

Python-only, no Windows and no GPU. Same host as the previous audit (Linux x86-64, Python 3.11.16, one LLVM library, 21.1).

Environment

  • worktree at dfd691825e, git status --porcelain --untracked-files=no empty.
  • fixture 6619ea3f… (555 lines), tools/startup/gfx2hlsl.py 928817ae… (11 945 lines) — unchanged by this commit, as a fixture-only amendment should be.
  • the previous fixture (2615baa8:tests/…, 520 lines, e842a42a…) run in the same tree, same tools, as the control.

Commands

python3 -B tests/startup_gfx2hlsl_far_early_out_check.py
python3 -B tests/startup_gfx2hlsl_far_early_out_check.py controls /usr/lib/x86_64-linux-gnu/libLLVM-21.so
# M1 at tools/startup/gfx2hlsl.py:1433 (mutated file sha256 1f7e64de…):
#   if asm != 's_endpgm' or at != ends[-1]:   ->   if asm != 's_endpgm':
python3 -B tests/startup_gfx2hlsl_far_early_out_check.py     # rc=1
python3 -B tests/_panam_old_far.py                            # rc=0, same mutant bytes

The clause is now pinned on the refusal side

Clean head: rc=0 and 16 refusals in both modes. Under M1 the amended fixture dies exactly on your new case —
AssertionError: continuation ends before the final exit: the startup translator accepted a refused program
(fixture line 352), after 13 refusals, so the two cases placed after it do not run. The 2615baa8 fixture, run
against the same mutated bytes, stays green (rc=0, 15 refusals). So the case you added is necessary and
sufficient for M1 on these programs, which was the ask. After git checkout --, gfx2hlsl.py is back to
928817ae…, git status empty, rc=0 again.

The acceptance side is not a gain of this commit

ends[-1] → ends[0] (94bce5e8…) is killed by the positive short calculated:
Unsupported: far early-out: the continuation ends at +0x58. That mutant kills the 2615baa8 fixture the same
way, so the pair brackets the comparison but only the refusal half is new.

asm != 's_endpgm' is unreachable, so M2 is equivalent rather than a hole

Dropping only that half leaves the fixture green, and it must: 0xbf810000, 0xbf810001 and 0xbf81ffff all
decode to (0, 4, 's_endpgm', 's_endpgm'), so when name == 's_endpgm' the text cannot differ. Treat it as
dead on today's decoder (a guard that would matter only if the decoder ever emitted a longer text), not as a
missing case.

The no-argument mode no longer uses resolve_libllvm()

main() sets library = None and passes it explicitly into check_variant and check_negatives, so the
module-level LIBRARY = resolve_libllvm() never reaches extract(). Measured on a directory holding
libLLVM-15.so.1 (a symlink to libLLVM-21.1) with LD_LIBRARY_PATH set and that directory as cwd:

  • resolve_libllvm() returns 'libLLVM-15.so.1' (printed from the fixture module);
  • the 2615baa8 fixture prints extracted exactly for the three variants, rc=0;
  • the dfd691825e fixture, same command, same cwd, prints extraction skipped (no LLVM 15 library found), rc=0.

So on a host that has the library the diagnostic is now wrong, and an extraction that used to run is skipped
silently. One line restores it while keeping controls <lib> explicit: library = LIBRARY in the no-argument
branch instead of library = None.

Where that lands

Read from the workflow file, not from a job log: pixel-binary runs this fixture as binary llvm-mc-15
(windows.yml:149) — two arguments, so check_binary receives library=None even though that is the job that
installs llvm-15 (:35) — and python-linux runs it with no arguments (:324) on ubuntu-24.04 with no LLVM
package installed (:195-197). No job exercises the extraction before or after this commit, so the docstring
line saying a binary-mode machine covers it was already inaccurate.

Limits

  • LLVM 21.1 stood in for 15 everywhere, both as the controls argument and behind the libLLVM-15.so.1 name:
    "LLVM 15 proper" is still not measured here.
  • Three mutants on one line, one of them equivalent; nothing was mutated in pixel_aot.
  • The refusals through pixel_aot.native_program are the same rule re-executed (pixel_aot.py:95 calls
    G.terminal_continuation_proof); that path's independent contribution is the LLVM-versus-repository-decoder
    inventory, not a second opinion on the clause.
  • No GPU, no Windows, no D3D12, no debug layer: nothing here says anything about the emitted HLSL executing.

AI-assisted.

**@⁠thepatrickworld** on GitHub · 2026-11-27 03:57 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2956#issuecomment-7209402965) **Follow-up on `dfd691825e`: the case you added does pin the distance clause, and the no-argument mode now ignores the library it finds** Python-only, no Windows and no GPU. Same host as the previous audit (Linux x86-64, Python 3.11.16, one LLVM library, 21.1). ### Environment - worktree at `dfd691825e`, `git status --porcelain --untracked-files=no` empty. - fixture `6619ea3f…` (555 lines), `tools/startup/gfx2hlsl.py` `928817ae…` (11 945 lines) — unchanged by this commit, as a fixture-only amendment should be. - the previous fixture (`2615baa8:tests/…`, 520 lines, `e842a42a…`) run in the same tree, same tools, as the control. ### Commands ``` python3 -B tests/startup_gfx2hlsl_far_early_out_check.py python3 -B tests/startup_gfx2hlsl_far_early_out_check.py controls /usr/lib/x86_64-linux-gnu/libLLVM-21.so # M1 at tools/startup/gfx2hlsl.py:1433 (mutated file sha256 1f7e64de…): # if asm != 's_endpgm' or at != ends[-1]: -> if asm != 's_endpgm': python3 -B tests/startup_gfx2hlsl_far_early_out_check.py # rc=1 python3 -B tests/_panam_old_far.py # rc=0, same mutant bytes ``` ### The clause is now pinned on the refusal side Clean head: rc=0 and 16 refusals in both modes. Under M1 the amended fixture dies exactly on your new case — `AssertionError: continuation ends before the final exit: the startup translator accepted a refused program` (fixture line 352), after 13 refusals, so the two cases placed after it do not run. The `2615baa8` fixture, run against the **same mutated bytes**, stays green (rc=0, 15 refusals). So the case you added is necessary and sufficient for M1 on these programs, which was the ask. After `git checkout --`, `gfx2hlsl.py` is back to `928817ae…`, `git status` empty, rc=0 again. ### The acceptance side is not a gain of this commit `ends[-1]` → `ends[0]` (`94bce5e8…`) is killed by the positive `short calculated`: `Unsupported: far early-out: the continuation ends at +0x58`. That mutant kills the `2615baa8` fixture the same way, so the pair brackets the comparison but only the refusal half is new. ### `asm != 's_endpgm'` is unreachable, so M2 is equivalent rather than a hole Dropping only that half leaves the fixture green, and it must: `0xbf810000`, `0xbf810001` and `0xbf81ffff` all decode to `(0, 4, 's_endpgm', 's_endpgm')`, so when `name == 's_endpgm'` the text cannot differ. Treat it as dead on today's decoder (a guard that would matter only if the decoder ever emitted a longer text), not as a missing case. ### The no-argument mode no longer uses `resolve_libllvm()` `main()` sets `library = None` and passes it explicitly into `check_variant` and `check_negatives`, so the module-level `LIBRARY = resolve_libllvm()` never reaches `extract()`. Measured on a directory holding `libLLVM-15.so.1` (a symlink to libLLVM-21.1) with `LD_LIBRARY_PATH` set and that directory as cwd: - `resolve_libllvm()` returns `'libLLVM-15.so.1'` (printed from the fixture module); - the `2615baa8` fixture prints `extracted exactly` for the three variants, rc=0; - the `dfd691825e` fixture, same command, same cwd, prints `extraction skipped (no LLVM 15 library found)`, rc=0. So on a host that has the library the diagnostic is now wrong, and an extraction that used to run is skipped silently. One line restores it while keeping `controls <lib>` explicit: `library = LIBRARY` in the no-argument branch instead of `library = None`. ### Where that lands Read from the workflow file, not from a job log: `pixel-binary` runs this fixture as `binary llvm-mc-15` (`windows.yml:149`) — two arguments, so `check_binary` receives `library=None` even though that is the job that installs llvm-15 (`:35`) — and `python-linux` runs it with no arguments (`:324`) on ubuntu-24.04 with no LLVM package installed (`:195-197`). No job exercises the extraction before or after this commit, so the docstring line saying a binary-mode machine covers it was already inaccurate. ### Limits - LLVM 21.1 stood in for 15 everywhere, both as the `controls` argument and behind the `libLLVM-15.so.1` name: "LLVM 15 proper" is still not measured here. - Three mutants on one line, one of them equivalent; nothing was mutated in `pixel_aot`. - The refusals through `pixel_aot.native_program` are the same rule re-executed (`pixel_aot.py:95` calls `G.terminal_continuation_proof`); that path's independent contribution is the LLVM-versus-repository-decoder inventory, not a second opinion on the clause. - No GPU, no Windows, no D3D12, no debug layer: nothing here says anything about the emitted HLSL executing. _AI-assisted._
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-27 04:00 UTC · original · reviewed

At dfd69182 I reproduced the dispatcher and refusal controls, including the earlier termination case, plus the calculated-target and startup cache-key suites. The head CI logs still leave the new extractor path out: Python printed extraction skipped (no LLVM 15 library found), and the LLVM job only reassembled the fixtures. Please pass libLLVM-15.so.1 to this fixture in the LLVM job, which already uses that library for the neighboring fixtures. That will keep extraction from silently dropping out of the test lane.

**@⁠R0Y00** on GitHub · 2026-11-27 04:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2956#pullrequestreview-6083313295) · **reviewed** At `dfd69182` I reproduced the dispatcher and refusal controls, including the earlier termination case, plus the calculated-target and startup cache-key suites. The head CI logs still leave the new extractor path out: Python printed `extraction skipped (no LLVM 15 library found)`, and the LLVM job only reassembled the fixtures. Please pass `libLLVM-15.so.1` to this fixture in the LLVM job, which already uses that library for the neighboring fixtures. That will keep extraction from silently dropping out of the test lane.
Author
Owner

@⁠chadhyatt on GitHub · 2026-11-27 04:01 UTC · original

Acknowledged. I will wire the existing LLVM15 extractor argument explicitly into the public LLVM job and keep the portable default diagnostic accurate. The source proof is unchanged.

**@⁠chadhyatt** on GitHub · 2026-11-27 04:01 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2956#issuecomment-7209455570) Acknowledged. I will wire the existing LLVM15 extractor argument explicitly into the public LLVM job and keep the portable default diagnostic accurate. The source proof is unchanged.
Author
Owner

@⁠chadhyatt on GitHub · 2026-11-27 04:02 UTC · original

Addressed at 537d7b923c: existing public LLVM job explicitly passes libLLVM-15.so.1; portable mode uses its discovered library when present. Actual Apple Silicon LLVM15 binary /opt/homebrew/opt/llvm@15/bin/llvm-mc /opt/homebrew/opt/llvm@15/lib/libLLVM-15.dylib passed exact assembly and extraction for all three variants. No-argument dispatcher and 16 refusals pass, with discovery skip reported on this host. Ready for follow-up.

**@⁠chadhyatt** on GitHub · 2026-11-27 04:02 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2956#issuecomment-7209467924) Addressed at 537d7b923cbd09356325ecf947e75a72b48d8a91: existing public LLVM job explicitly passes `libLLVM-15.so.1`; portable mode uses its discovered library when present. Actual Apple Silicon LLVM15 `binary /opt/homebrew/opt/llvm@15/bin/llvm-mc /opt/homebrew/opt/llvm@15/lib/libLLVM-15.dylib` passed exact assembly and extraction for all three variants. No-argument dispatcher and 16 refusals pass, with discovery skip reported on this host. Ready for follow-up.
Pass the same explicit LLVM15 library as neighboring binary fixtures, and restore optional library discovery in portable mode.
github-bot changed target branch from main to gh-pr/2956/base 2026-11-27 04:23:56 +00:00
github manually merged commit 537d7b923c into gh-pr/2956/base 2026-11-27 04:23:57 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-27 04:19 UTC · original · approved these changes

Reviewed 537d7b923cbd09356325ecf947e75a72b48d8a91. The LLVM job now explicitly invokes binary llvm-mc-15 libLLVM-15.so.1; I checked the job log and it confirms byte-exact assembly and extraction for all three variants. Independently reran the far-early-out and calculated-target Python checks on the exact head: all portable controls passed, while local LLVM extraction was skipped on Windows. Required Windows CI passed.

**@⁠R0Y00** on GitHub · 2026-11-27 04:19 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2956#pullrequestreview-6083442828) · **approved these changes** Reviewed `537d7b923cbd09356325ecf947e75a72b48d8a91`. The LLVM job now explicitly invokes `binary llvm-mc-15 libLLVM-15.so.1`; I checked the job log and it confirms byte-exact assembly and extraction for all three variants. Independently reran the far-early-out and calculated-target Python checks on the exact head: all portable controls passed, while local LLVM extraction was skipped on Windows. Required Windows CI passed.
Author
Owner

@⁠KelboLive on GitHub · 2026-11-27 04:33 UTC · original · reviewed

PR #2956 admits proven calculated far early-outs in the gfx1013 pixel two-exit profile. The
chain-verification is thorough and the 555-line test matrix is excellent.

What works

  • The GETPC/ADD/ADDC/SETPC chain validation is precise: contiguous four instructions starting with
    s_getpc_b64, middle two must be exactly s_add_u32 and s_addc_u32, last two instructions must target
    s[%d:%d] set from GETPC pair. Matches the documented pattern.
  • sign extension check: extension must equal (-1 if displacement < 0 else 0). Correctly rejects positive
    extension on signed displacement and zero-extension on negative displacement.
  • terminal_continuation_proof: exactly ONE transfer via SETPC, exactly TWO s_endpgm labels, the target
    must be forward (target > setpc). A single exit or backward jumps are refused.
  • The negative control matrix is comprehensive (11+ cases): register-derived displacement, missing ADDC,
    wrong sign extension, signed ADD instead of ADDC, competing entry into chain, pair clobbering, address/SCC
    escape, stale scratch pair, effectful continuation (export/store/barrier/EXEC), wrong endpgm, off-boundary
    target, out-of-range target, and non-forward target.
  • _calculated_early_out in pixel_aot.py: verifies the LLVM and repository decoders agree on the instruction
    inventory before accepting the chain. Good invariant.
  • _check_two_exits now passes an early_out flag: cleanly orthogonal to the mesh flag. The mesh path is
    excluded from far-early-out acceptance (mesh has its own export model).

Issues

  1. Chain pair constraint: the GETPC pair is inferred from the first GETPC instruction. If a function uses
    GETPC on different registers across functions, the chain form changes. The verifier picks whichever pair
    the GETPC happens to use. This is correct but pairs should ideally be consistent across callers for
    determinism. Otherwise, the pair choice is per-function.
  2. Continuation internal branches: the terminal check allows s_nop and v_nop and s_endpgm, but does NOT
    explicitly refuse internal branches in the continuation. Consider adding an explicit branch-refusal check.
  3. GETPC pair freshness: between the GETPC and SETPC, the scalar pair may be used by other compute.
    The proof assumes the GETPC value is read before the pair is clobbered. This matches the PR description
    requiring a fresh aligned scalar pair. No bug, but worth noting for anyone reasoning about the proof.
  4. calculated_early_out lazy import: pixel_aot imports gfx2hlsl symbols via G.decode and G.calculated_pc
    proof. The import comment notes gfx2hlsl also imports pixel_aot lazily, so order should be stable.

Recommendations

  • Add an explicit refusal for branches within the terminal continuation body.
  • Add a comment documenting pair inference behavior in terminal_continuation_proof.
  • Consider logging once when far early-outs are admitted for diagnostic visibility.

Overall: excellent PR. The chain verification is carefully constructed and the test matrix covers edge
cases that would otherwise slip through. Enables more complex control flow in translated programs.

**@⁠KelboLive** on GitHub · 2026-11-27 04:33 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2956#pullrequestreview-6083522950) · **reviewed** PR #2956 admits proven calculated far early-outs in the gfx1013 pixel two-exit profile. The chain-verification is thorough and the 555-line test matrix is excellent. ## What works - The GETPC/ADD/ADDC/SETPC chain validation is precise: contiguous four instructions starting with s_getpc_b64, middle two must be exactly s_add_u32 and s_addc_u32, last two instructions must target s[%d:%d] set from GETPC pair. Matches the documented pattern. - sign extension check: extension must equal (-1 if displacement < 0 else 0). Correctly rejects positive extension on signed displacement and zero-extension on negative displacement. - terminal_continuation_proof: exactly ONE transfer via SETPC, exactly TWO s_endpgm labels, the target must be forward (target > setpc). A single exit or backward jumps are refused. - The negative control matrix is comprehensive (11+ cases): register-derived displacement, missing ADDC, wrong sign extension, signed ADD instead of ADDC, competing entry into chain, pair clobbering, address/SCC escape, stale scratch pair, effectful continuation (export/store/barrier/EXEC), wrong endpgm, off-boundary target, out-of-range target, and non-forward target. - _calculated_early_out in pixel_aot.py: verifies the LLVM and repository decoders agree on the instruction inventory before accepting the chain. Good invariant. - _check_two_exits now passes an early_out flag: cleanly orthogonal to the mesh flag. The mesh path is excluded from far-early-out acceptance (mesh has its own export model). ## Issues 1. Chain pair constraint: the GETPC pair is inferred from the first GETPC instruction. If a function uses GETPC on different registers across functions, the chain form changes. The verifier picks whichever pair the GETPC happens to use. This is correct but pairs should ideally be consistent across callers for determinism. Otherwise, the pair choice is per-function. 2. Continuation internal branches: the terminal check allows s_nop and v_nop and s_endpgm, but does NOT explicitly refuse internal branches in the continuation. Consider adding an explicit branch-refusal check. 3. GETPC pair freshness: between the GETPC and SETPC, the scalar pair may be used by other compute. The proof assumes the GETPC value is read before the pair is clobbered. This matches the PR description requiring a fresh aligned scalar pair. No bug, but worth noting for anyone reasoning about the proof. 4. _calculated_early_out lazy import: pixel_aot imports gfx2hlsl symbols via G.decode and G.calculated_pc_ proof. The import comment notes gfx2hlsl also imports pixel_aot lazily, so order should be stable. ## Recommendations - Add an explicit refusal for branches within the terminal continuation body. - Add a comment documenting pair inference behavior in terminal_continuation_proof. - Consider logging once when far early-outs are admitted for diagnostic visibility. Overall: excellent PR. The chain verification is carefully constructed and the test matrix covers edge cases that would otherwise slip through. Enables more complex control flow in translated programs.
Author
Owner

@⁠thepatrickworld on GitHub · 2026-11-27 07:59 UTC · original

Post-merge receipt on 9436a181: the no-argument run now drives 19 extraction sites, the calculated early-out extraction re-runs the translator's proofs, and CI exercises three of them

Python-only, no Windows, no GPU. Same host as my two earlier audits (Linux x86-64, CPython 3.11.16, one LLVM library, 21.1).

Tree measured

  • single-parent commit 9436a181 (squash of this PR); git status --porcelain --untracked-files=no empty before and after the runs.
  • tests/startup_gfx2hlsl_far_early_out_check.py 51a49457… and .github/workflows/windows.yml a4196088… are byte-identical to the head 537d7b92 I measured earlier (sha256 equal at both refs), so the fixture I ran is byte-identical to the delivered one and the workflow line I quote is the delivered one; no CI job was run here. tools/startup/gfx2hlsl.py (9d9f09fe…) differs from that head by other merges, not by this one.

Commands

The cwd matters: resolve_libllvm() tests libLLVM-15.so.1 as a relative path, and LLVM 21.1 sits behind that name in the directory used below.

cd /root/repos/logs2956/llvm15dir && LD_LIBRARY_PATH=$PWD \
  PYTHONPATH=/root/repos/wt2956_merge/tests:/root/repos/wt2956_merge/tools/startup \
  python3 -B /root/repos/wt2956_merge/tests/startup_gfx2hlsl_far_early_out_check.py
# same prefix, script argument `controls libLLVM-15.so.1`
# and the control: … python3 -B /root/repos/wt2956_merge/tests/_panam_old_far.py

From the repository root instead, the same first command prints extraction skipped ×19, and controls libLLVM-15.so.1 exits 1 on the docstring (Path(argv[2]).is_file()).

Observed

  • no argument: extracted exactly ×3, extraction skipped ×0, 16 refusal lines carrying the translator's diagnostics with no skip suffix; rc=0. controls libLLVM-15.so.1 gives the same three exact extractions and the same 16 refusals.
  • old fixture bytes (dfd69182, 6619ea3f…, written to tests/_panam_old_far.py in the same tree and removed afterwards; its only difference from the delivered fixture in main() is library = LIBRARY → library = None), same cwd and env: extraction skipped (no LLVM 15 library found) ×19, extracted exactly ×0; rc=0.

So the one line moves 19 extraction sites, not 3: the three variants, plus the 16 refusal controls whose stage_and_extract() returns None when no library is selected (tests/startup_gfx2hlsl_far_early_out_check.py:389).

What the extraction half actually gates

extract(...) == code alone is a container round-trip: container_code returns a slice of the FSSM image it just re-read, so every program it accepts comes back byte-identical — a valid short variant with word 18 changed from s_nop 0 to s_nop 1 comes back EXACT too.
The gate that can fail sits before that return, in _check_two_exits (tools/pixel_aot.py:103): it disassembles with LLVM, requires the LLVM inventory to agree with the repository decoder, walks the CFG to both exits, and — when the program carries s_getpc_b64 — replays calculated_pc_proof and terminal_continuation_proof (tools/startup/gfx2hlsl.py:1167, :1377, the two functions Stage.translate calls at :3571 and :3578).
Measured on the merged tree, on the short variant (s_cbranch_scc0 at pc 44, s_branch at pc 56):

  • word 11 replaced by s_nop 0 gives ValueError: Unreachable code or unverified alternate exit, and the same for word 14;
  • a third s_endpgm gives Unverified multi-exit program, and a word after the last exit Expected termination followed by code padding — both raised earlier, inside container_code (the marker count and _bounded_code);
  • without a library, container_code still returns a one-exit program but refuses these two-exit ones, so extract(..., None) raises Unverified multi-exit program for all three variants: the if library is not None in check_binary (tests/startup_gfx2hlsl_far_early_out_check.py:544) is what keeps binary <mc> runnable on a host without a library.
    Not covered by this half: HLSL emission, the dispatcher oracle, the arithmetic.

Where CI only exercises three of the 19

check_binary asserts extraction for the three variants only, and check_negatives is reached only from main() after the binary branch has returned. So at this sha pixel-binary exercises the extraction of the three variants and no refusal control (.github/workflows/windows.yml:149; its run at 537d7b92 concluded success), while python-linux runs the no-argument mode on ubuntu-24.04, whose published image lists clang 16/17/18 and no clang 15 (runner-images Ubuntu2404-Readme.md, image 20261116.376.1), and the job itself installs only requirements-dev.txt — on such an image resolve_libllvm() has no libLLVM-15.so.1 to return. I could not read the job log, so that last point is the image's package list, not a run trace.
If the 16 refusal controls should go through the extractor in CI, the list at :149 can carry a second entry (["tests/startup_gfx2hlsl_far_early_out_check.py", "controls", "<absolute libLLVM-15.so.1 path>"], {}): that job installs llvm-15, but main() requires an existing file and run_checks_parallel keeps the repository root as cwd, so the bare soname the neighbouring entries pass exits on the docstring.

Limits

  • the library actually loaded was LLVM 21.1 under the expected name libLLVM-15.so.1 (LD_LIBRARY_PATH for the load); no llvm-mc on this host, so binary <mc> <lib> was read, not executed.
  • not read: the log of pixel-binary at 537d7b92 (run 45937575194, job 140304215556, success), so what it printed is not quoted here.
  • what LLVM 15 versus 21.1 does to the inventory comparison is not measured.
  • nothing here covers GPU, Windows or the emitted HLSL.

AI-assisted.

**@⁠thepatrickworld** on GitHub · 2026-11-27 07:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2956#issuecomment-7213015013) **Post-merge receipt on `9436a181`: the no-argument run now drives 19 extraction sites, the calculated early-out extraction re-runs the translator's proofs, and CI exercises three of them** Python-only, no Windows, no GPU. Same host as my two earlier audits (Linux x86-64, CPython 3.11.16, one LLVM library, 21.1). ### Tree measured - single-parent commit `9436a181` (squash of this PR); `git status --porcelain --untracked-files=no` empty before and after the runs. - `tests/startup_gfx2hlsl_far_early_out_check.py` `51a49457…` and `.github/workflows/windows.yml` `a4196088…` are byte-identical to the head `537d7b92` I measured earlier (sha256 equal at both refs), so the fixture I ran is byte-identical to the delivered one and the workflow line I quote is the delivered one; no CI job was run here. `tools/startup/gfx2hlsl.py` (`9d9f09fe…`) differs from that head by other merges, not by this one. ### Commands The cwd matters: `resolve_libllvm()` tests `libLLVM-15.so.1` as a relative path, and LLVM 21.1 sits behind that name in the directory used below. ``` cd /root/repos/logs2956/llvm15dir && LD_LIBRARY_PATH=$PWD \ PYTHONPATH=/root/repos/wt2956_merge/tests:/root/repos/wt2956_merge/tools/startup \ python3 -B /root/repos/wt2956_merge/tests/startup_gfx2hlsl_far_early_out_check.py # same prefix, script argument `controls libLLVM-15.so.1` # and the control: … python3 -B /root/repos/wt2956_merge/tests/_panam_old_far.py ``` From the repository root instead, the same first command prints `extraction skipped` ×19, and `controls libLLVM-15.so.1` exits 1 on the docstring (`Path(argv[2]).is_file()`). ### Observed - no argument: `extracted exactly` ×3, `extraction skipped` ×0, 16 refusal lines carrying the translator's diagnostics with no skip suffix; rc=0. `controls libLLVM-15.so.1` gives the same three exact extractions and the same 16 refusals. - old fixture bytes (`dfd69182`, `6619ea3f…`, written to `tests/_panam_old_far.py` in the same tree and removed afterwards; its only difference from the delivered fixture in `main()` is `library = LIBRARY` → `library = None`), same cwd and env: `extraction skipped (no LLVM 15 library found)` ×19, `extracted exactly` ×0; rc=0. So the one line moves 19 extraction sites, not 3: the three variants, plus the 16 refusal controls whose `stage_and_extract()` returns `None` when no library is selected (`tests/startup_gfx2hlsl_far_early_out_check.py:389`). ### What the extraction half actually gates `extract(...) == code` alone is a container round-trip: `container_code` returns a slice of the FSSM image it just re-read, so every program it accepts comes back byte-identical — a valid `short` variant with word 18 changed from `s_nop 0` to `s_nop 1` comes back EXACT too. The gate that can fail sits before that return, in `_check_two_exits` (`tools/pixel_aot.py:103`): it disassembles with LLVM, requires the LLVM inventory to agree with the repository decoder, walks the CFG to both exits, and — when the program carries `s_getpc_b64` — replays `calculated_pc_proof` and `terminal_continuation_proof` (`tools/startup/gfx2hlsl.py:1167`, `:1377`, the two functions `Stage.translate` calls at `:3571` and `:3578`). Measured on the merged tree, on the `short` variant (`s_cbranch_scc0` at pc 44, `s_branch` at pc 56): - word 11 replaced by `s_nop 0` gives `ValueError: Unreachable code or unverified alternate exit`, and the same for word 14; - a third `s_endpgm` gives `Unverified multi-exit program`, and a word after the last exit `Expected termination followed by code padding` — both raised earlier, inside `container_code` (the marker count and `_bounded_code`); - without a library, `container_code` still returns a one-exit program but refuses these two-exit ones, so `extract(..., None)` raises `Unverified multi-exit program` for all three variants: the `if library is not None` in `check_binary` (`tests/startup_gfx2hlsl_far_early_out_check.py:544`) is what keeps `binary <mc>` runnable on a host without a library. Not covered by this half: HLSL emission, the dispatcher oracle, the arithmetic. ### Where CI only exercises three of the 19 `check_binary` asserts extraction for the three variants only, and `check_negatives` is reached only from `main()` after the `binary` branch has returned. So at this sha `pixel-binary` exercises the extraction of the three variants and no refusal control (`.github/workflows/windows.yml:149`; its run at `537d7b92` concluded success), while `python-linux` runs the no-argument mode on ubuntu-24.04, whose published image lists clang 16/17/18 and no clang 15 (runner-images `Ubuntu2404-Readme.md`, image 20261116.376.1), and the job itself installs only `requirements-dev.txt` — on such an image `resolve_libllvm()` has no `libLLVM-15.so.1` to return. I could not read the job log, so that last point is the image's package list, not a run trace. If the 16 refusal controls should go through the extractor in CI, the list at `:149` can carry a second entry `(["tests/startup_gfx2hlsl_far_early_out_check.py", "controls", "<absolute libLLVM-15.so.1 path>"], {})`: that job installs `llvm-15`, but `main()` requires an existing file and `run_checks_parallel` keeps the repository root as cwd, so the bare soname the neighbouring entries pass exits on the docstring. ### Limits - the library actually loaded was LLVM 21.1 under the expected name `libLLVM-15.so.1` (`LD_LIBRARY_PATH` for the load); no `llvm-mc` on this host, so `binary <mc> <lib>` was read, not executed. - not read: the log of `pixel-binary` at `537d7b92` (run 45937575194, job 140304215556, success), so what it printed is not quoted here. - what LLVM 15 versus 21.1 does to the inventory comparison is not measured. - nothing here covers GPU, Windows or the emitted HLSL. _AI-assisted._
This discussion has been locked. Commenting is limited to contributors.
No description provided.