Recompiler: compact DXIL bitcode tables, types, and interned constants #3645

Open
Kalmarv wants to merge 1 commit from upstream-pr/3645 into main
Kalmarv commented 2026-12-02 03:21:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T03:21:18Z.


What is in it

Compacts emitted direct-DXIL bitcode tables, prunes dead types across entry and internal helper bodies, and caches interned scalar types, register constants, and intrinsic declarations (+991/-200 across 9 files in crates/xcl/src/gpu/dxil/: +604/-198 production code and +387/-2 unit/bitreader/DXC-validation tests).

  • Dead-type pruning and constant grouping (module.rs):
    • Prune unused types across entry instructions, globals, constants, metadata, and live #3655 internal HelperBody functions (live_types, helper_local_types) before emitting BLOCK_TYPE.
    • Cache each function's address-space-0 pointer type (FuncDecl::ptr) in declare() (matching GlobalDef::ptr) so value_ty is total and O(1) across optimize(), read-only scans, and emission while live_types prunes unused function pointer types from BLOCK_TYPE.
    • Group live module constants by (nesting depth, remapped type) so CST_CODE_SETTYPE is emitted once per live type while keeping aggregate elements ahead of parents, and reject non-constant Value::Inst elements deterministically in Module::aggregate().
  • Bitcode table abbreviations and fitted operand widths (bitstream.rs, module.rs, bitreader_tests.rs):
    • Add standard LLVM 3.7 ArrayChar6 encoding and abbreviate MODULE_CODE_FUNCTION (preserving prototype flag, internal/external linkage for helper bodies, and FnAttrs::MAX_INDEX attribute width), BLOCK_TYPE struct/pointer/function records, BLOCK_METADATA strings/names/nodes, and VALUE_SYMTAB entries.
    • Fit ty_w, sym_w, md_idx_w, val_w, val_rel_w, and bb_w across both the entry body and all live helper bodies, and tighten function-block VBR widths.
    • Check fixed-field widths, abbrev IDs, and ArrayChar6 operands at runtime in BitWriter and surface errors through BitWriter::try_finish / Module::try_to_bitcode instead of silently truncating in release builds.
  • Interning & lookup caches (module.rs, module/split.rs, shader.rs, ops.rs, lower.rs, lower_valu.rs):
    • Reuse interned IDs for common scalar types (scalar_types), small i32 constants (small_words, preserved by Module::declarations()), and matching dx.op.* declarations (dx_ops).
    • Inspect scalar widths via int_width/float_width without interning unused 64-bit types during lowering.
  • Tests (bitstream.rs, module.rs, bitreader_tests.rs, core_tests.rs):
    • Updated compute_omits_rodata_without_s_getpc to store the loaded value so the s_getpc_b64 case checks a live xcl_rodata probe instead of an unpruned dead array type.
    • Added unit, bitreader, and DXC-validation tests covering dead-type pruning, constant grouping, Char6/fallback round-trips, #3655 helper-only types and wider helper val_rel_w/bb_w widths (helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths), DXC validation of spin_wait/barrier_arrive helpers (spin_wait_and_barrier_arrive_helpers_validate_with_compacted_bitcode), Value::Func operands across optimize() + unused function-pointer pruning (func_value_operand_survives_optimize_and_prunes_unused_func_ptrs), deterministic Value::Inst rejection in Module::aggregate() (aggregate_constant_with_inst_operand_returns_error), and BitWriter fixed-field overflow errors (fixed_field_overflow_returns_error_instead_of_corrupting_stream).
  • Why this is kept as one PR: The non-test diff is +604/-198 (the remaining +387/-2 lines are tests). Dead-type pruning, non-interning width queries, and the fitted table abbreviations work as one encoding pass in module.rs because pruning determines the exact live ty_w used across BLOCK_TYPE, BLOCK_CONSTANTS, BLOCK_METADATA, MODULE_CODE_FUNCTION, and FuncAbbrevs.

Tested

  • Hardware & toolchain: NVIDIA GeForce RTX 5070 Ti (driver 610.74), AMD Ryzen 9 9950X 16-Core, Windows 11 Pro 26200, rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9.2609.5 (debug + release).
  • On cecb51868 (rebased onto main a815de932 after #3707, with zero production-code diff vs 66afe7a64 — only helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths updated to call m.write_bitcode(...) directly before #3707's inline_helpers()):
    • cargo build --release -p xcl: clean (39 warnings; 0 new vs main).
    • cargo test --release -p xcl --lib -- dxil --skip gpu_ --skip fuzz_validate_and_gpu --skip bfm_and_ffbh_i_ir_and_gpu_parity --test-threads=4 (DXC 1.9.2609.5): 359 passed, 0 failed, 4 ignored (12 SKIPPED no wave64 subcases in lower_dxil::tests; all 28 tests across gpu::dxil::bitstream::tests, gpu::dxil::bitreader_tests, and gpu::dxil::module::tests passed, including helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths and #3707's inlined_rendezvous_is_one_loop_with_one_exit_and_first_lane_atomics).
  • On 66afe7a64 (identical production code before the #3707 rebase):
    • scripts/test.ps1 (cargo build --workspace, cargo bench -p xcl --bench '*' -- --test, cargo test --workspace -- --test-threads=4, DXC 1.9.2609.5): 2987 passed, 0 failed, 52 ignored across all 43 test targets (24 SKIPPED GPU tests on this adapter: 22 no wave64, 2 no heap windows; 0 DXC skips).

Regression run

Regression check only (same title; cecb51868 is a single cold-translated-cache 60 s run after the 1-line test edit in module.rs changed XCL_DIRECT_DXIL_SOURCE_ID, settling at 60 61 60 presents per 2 s; prior warm 60 s runs on identical production code 66afe7a64 recorded 1702 and 1707 frames, 60 60 60, 0 removals, 0 crashes, 16118–16300 MB peak commit). No memory or frame-rate speedup is claimed from the smoke delta.

Baseline (main):

xcl-smoke v1
commit: 5eaadb54c14e0fc29597b2a1689d7dbd83491303
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1700 (PresentX 1700)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16914 MB

PR head:

xcl-smoke v1
commit: cecb518680e7d199b14cc9c30eb67f1c330d788f
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1373 (PresentX 1373)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 15118 MB

Not tested

  • AMD and Intel GPUs/drivers (including native wave64 hardware paths; 22 wave64 GPU tests skipped on RTX 5070 Ti). All emitted encodings are standard LLVM 3.7 bitstream records/abbreviations validated by DXC 1.9.2609.5 and NVIDIA, but AMD's DXIL reader has not yet executed them.
  • Opt-in XCL_HEAP_WINDOWS=1 GPU tests (2 skipped under default scripts/test.ps1).
  • Full scripts/test.ps1 / gpu_* tests were not re-run locally on cecb51868 (production code is unchanged vs 66afe7a64, where the full suite passed 2987/0/52).
  • Offline corpus bitcode-size and per-shader translation-time benchmarks were not re-measured on cecb51868.

AI use

  • Codex (GPT-6) wrote the initial bitcode compaction and interning changes during an offline DXIL size sweep.
  • Antigravity (Gemini 4 Neon) cherry-picked and rebased them onto main (a815de932), fixed the #3655 HelperBody integration, @bmjask's Value::Func / Module::aggregate / BitWriter findings, and the #3707 helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths test update, ran cargo build --release -p xcl, DXIL unit tests (cecb51868), full scripts/test.ps1 (66afe7a64), and the 60 s smoke runs, and drafted this description.
<!-- greyfinch-sync:ivall/xcl:issue:5599170203 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T03:21:18Z. --- **What is in it** Compacts emitted direct-DXIL bitcode tables, prunes dead types across entry and internal helper bodies, and caches interned scalar types, register constants, and intrinsic declarations (`+991/-200` across 9 files in `crates/xcl/src/gpu/dxil/`: `+604/-198` production code and `+387/-2` unit/bitreader/DXC-validation tests). - **Dead-type pruning and constant grouping (`module.rs`):** - Prune unused types across entry instructions, globals, constants, metadata, and live `#3655` internal `HelperBody` functions (`live_types`, `helper_local_types`) before emitting `BLOCK_TYPE`. - Cache each function's address-space-0 pointer type (`FuncDecl::ptr`) in `declare()` (matching `GlobalDef::ptr`) so `value_ty` is total and O(1) across `optimize()`, read-only scans, and emission while `live_types` prunes unused function pointer types from `BLOCK_TYPE`. - Group live module constants by `(nesting depth, remapped type)` so `CST_CODE_SETTYPE` is emitted once per live type while keeping aggregate elements ahead of parents, and reject non-constant `Value::Inst` elements deterministically in `Module::aggregate()`. - **Bitcode table abbreviations and fitted operand widths (`bitstream.rs`, `module.rs`, `bitreader_tests.rs`):** - Add standard LLVM 3.7 `ArrayChar6` encoding and abbreviate `MODULE_CODE_FUNCTION` (preserving prototype flag, internal/external linkage for helper bodies, and `FnAttrs::MAX_INDEX` attribute width), `BLOCK_TYPE` struct/pointer/function records, `BLOCK_METADATA` strings/names/nodes, and `VALUE_SYMTAB` entries. - Fit `ty_w`, `sym_w`, `md_idx_w`, `val_w`, `val_rel_w`, and `bb_w` across both the entry body and all live helper bodies, and tighten function-block VBR widths. - Check fixed-field widths, abbrev IDs, and `ArrayChar6` operands at runtime in `BitWriter` and surface errors through `BitWriter::try_finish` / `Module::try_to_bitcode` instead of silently truncating in release builds. - **Interning & lookup caches (`module.rs`, `module/split.rs`, `shader.rs`, `ops.rs`, `lower.rs`, `lower_valu.rs`):** - Reuse interned IDs for common scalar types (`scalar_types`), small `i32` constants (`small_words`, preserved by `Module::declarations()`), and matching `dx.op.*` declarations (`dx_ops`). - Inspect scalar widths via `int_width`/`float_width` without interning unused 64-bit types during lowering. - **Tests (`bitstream.rs`, `module.rs`, `bitreader_tests.rs`, `core_tests.rs`):** - Updated `compute_omits_rodata_without_s_getpc` to store the loaded value so the `s_getpc_b64` case checks a live `xcl_rodata` probe instead of an unpruned dead array type. - Added unit, bitreader, and DXC-validation tests covering dead-type pruning, constant grouping, Char6/fallback round-trips, `#3655` helper-only types and wider helper `val_rel_w`/`bb_w` widths (`helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths`), DXC validation of `spin_wait`/`barrier_arrive` helpers (`spin_wait_and_barrier_arrive_helpers_validate_with_compacted_bitcode`), `Value::Func` operands across `optimize()` + unused function-pointer pruning (`func_value_operand_survives_optimize_and_prunes_unused_func_ptrs`), deterministic `Value::Inst` rejection in `Module::aggregate()` (`aggregate_constant_with_inst_operand_returns_error`), and `BitWriter` fixed-field overflow errors (`fixed_field_overflow_returns_error_instead_of_corrupting_stream`). - **Why this is kept as one PR:** The non-test diff is `+604/-198` (the remaining `+387/-2` lines are tests). Dead-type pruning, non-interning width queries, and the fitted table abbreviations work as one encoding pass in `module.rs` because pruning determines the exact live `ty_w` used across `BLOCK_TYPE`, `BLOCK_CONSTANTS`, `BLOCK_METADATA`, `MODULE_CODE_FUNCTION`, and `FuncAbbrevs`. **Tested** - Hardware & toolchain: NVIDIA GeForce RTX 5070 Ti (driver 610.74), AMD Ryzen 9 9950X 16-Core, Windows 11 Pro 26200, `rustc 1.99.0 (b940084d7 2026-09-28)`, DXC `1.9.2609.5` (debug + release). - On `cecb51868` (rebased onto `main` `a815de932` after `#3707`, with zero production-code diff vs `66afe7a64` — only `helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths` updated to call `m.write_bitcode(...)` directly before `#3707`'s `inline_helpers()`): - `cargo build --release -p xcl`: clean (39 warnings; 0 new vs `main`). - `cargo test --release -p xcl --lib -- dxil --skip gpu_ --skip fuzz_validate_and_gpu --skip bfm_and_ffbh_i_ir_and_gpu_parity --test-threads=4` (DXC `1.9.2609.5`): **359 passed, 0 failed, 4 ignored** (12 `SKIPPED` `no wave64` subcases in `lower_dxil::tests`; all 28 tests across `gpu::dxil::bitstream::tests`, `gpu::dxil::bitreader_tests`, and `gpu::dxil::module::tests` passed, including `helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths` and `#3707`'s `inlined_rendezvous_is_one_loop_with_one_exit_and_first_lane_atomics`). - On `66afe7a64` (identical production code before the `#3707` rebase): - `scripts/test.ps1` (`cargo build --workspace`, `cargo bench -p xcl --bench '*' -- --test`, `cargo test --workspace -- --test-threads=4`, DXC `1.9.2609.5`): **2987 passed, 0 failed, 52 ignored** across all 43 test targets (24 `SKIPPED` GPU tests on this adapter: 22 `no wave64`, 2 `no heap windows`; 0 DXC skips). **Regression run** Regression check only (same title; `cecb51868` is a single cold-translated-cache 60 s run after the 1-line test edit in `module.rs` changed `XCL_DIRECT_DXIL_SOURCE_ID`, settling at `60 61 60` presents per 2 s; prior warm 60 s runs on identical production code `66afe7a64` recorded 1702 and 1707 frames, `60 60 60`, 0 removals, 0 crashes, 16118–16300 MB peak commit). No memory or frame-rate speedup is claimed from the smoke delta. Baseline (`main`): ``` xcl-smoke v1 commit: 5eaadb54c14e0fc29597b2a1689d7dbd83491303 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1700 (PresentX 1700) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16914 MB ``` PR head: ``` xcl-smoke v1 commit: cecb518680e7d199b14cc9c30eb67f1c330d788f gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1373 (PresentX 1373) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 15118 MB ``` **Not tested** - AMD and Intel GPUs/drivers (including native wave64 hardware paths; 22 wave64 GPU tests skipped on RTX 5070 Ti). All emitted encodings are standard LLVM 3.7 bitstream records/abbreviations validated by DXC `1.9.2609.5` and NVIDIA, but AMD's DXIL reader has not yet executed them. - Opt-in `XCL_HEAP_WINDOWS=1` GPU tests (2 skipped under default `scripts/test.ps1`). - Full `scripts/test.ps1` / `gpu_*` tests were not re-run locally on `cecb51868` (production code is unchanged vs `66afe7a64`, where the full suite passed 2987/0/52). - Offline corpus bitcode-size and per-shader translation-time benchmarks were not re-measured on `cecb51868`. **AI use** - Codex (`GPT-6`) wrote the initial bitcode compaction and interning changes during an offline DXIL size sweep. - Antigravity (`Gemini 4 Neon`) cherry-picked and rebased them onto `main` (`a815de932`), fixed the `#3655` `HelperBody` integration, `@bmjask`'s `Value::Func` / `Module::aggregate` / `BitWriter` findings, and the `#3707` `helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths` test update, ran `cargo build --release -p xcl`, DXIL unit tests (`cecb51868`), full `scripts/test.ps1` (`66afe7a64`), and the 60 s smoke runs, and drafted this description.
SavageCore commented 2026-12-02 04:31:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SavageCore on 2026-12-02T04:31:10Z.

Review: APPROVED


sorry, ignore, agent went crazy

<!-- greyfinch-sync:ivall/xcl:review:6144788677 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#pullrequestreview-6144788677). Originally posted by [SavageCore](https://github.com/SavageCore) on 2026-12-02T04:31:10Z. **Review:** APPROVED --- sorry, ignore, agent went crazy
Foniass commented 2026-12-02 08:59:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T08:59:17Z.


Review (head bc479215, diff read, not a merge-check):

  • Size and scope. +698/-167 (865 changed lines) in one commit that bundles five independent changes: dead-type pruning with constant regrouping, Char6/fixed-width table abbreviations, narrower function-block operand widths, the interning caches (scalar_types, small_words, dx_ops), and the scalar-width queries in ops.rs/shader.rs/lower*.rs. CONTRIBUTING asks a PR over ~800 lines to say why it cannot be split, and the description does not. Each of these parts builds and can be checked on its own. Splitting would also let a bisect find which encoding change a driver objects to.
  • Semantic conflict with #3655, not only a textual one. live_types (module.rs ~1336) marks types only from entry-body instructions in order, and val_rel_w/bb_w come from the entry body only. #3655 writes internal helper bodies from body.instructions with raw inst.ty.0 type IDs (#3655 module.rs ~1289). After both merge, a type that only a helper uses either hits expect("use of a dropped type") or is written with an unremapped ID. #3654 (stacked on this PR) already extends mark_inst and max_inst_id to cover its helper bodies. Whichever of #3645/#3655 lands second has to make the same change for #3655's bodies.
  • Measured-impact claims are not this tree's. The per-pass byte and p50 savings come from a separate sweep branch ("Not tested" says so). The -2244 MB peak commit comes from a single smoke pair, and a bitcode reduction of about 0.8 MB over 329 shaders cannot explain it. Please present the smoke numbers as a regression check only, or show where the memory goes.
  • On by default, one vendor. Every direct-DXIL shader now gets the new type numbering, constant order and abbreviations, with no switch. Validation and the smoke run were done on NVIDIA only. The encodings are standard LLVM bitstream features, but AMD's DXIL reader has not run them. The tests round-trip only through the in-repo bitreader_tests reader, written alongside the writer, and the DXC-validation tests SKIP without DXC.

Fine (by reading): the Char6 table and Array/Char6 abbrev encoding match LLVM. Every Fixed width covers its maximum value: ty_w, sym_w, md_idx_w, val_w, bb_w, and val_rel_w for callee and GEP pointer relative IDs. The paramattr index (≤4) and linkage (0/3) fit their fixed fields. Each block has at most 4 user abbrevs at width 3 (settype falls back to an unabbreviated record when 4 are in use). The pruned type table keeps children before parents. Constant regrouping by (depth, type) keeps aggregate elements first, and every reference goes through cmap/tmap. declarations() copies small_words together with consts, and the dx_ops cache rechecks name, suffix, return and parameter types. compute_omits_rodata_without_s_getpc still asserts the same thing, now with a live use.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7340204231 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#issuecomment-7340204231). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T08:59:17Z. --- Review (head bc479215, diff read, not a merge-check): - **Size and scope.** +698/-167 (865 changed lines) in one commit that bundles five independent changes: dead-type pruning with constant regrouping, Char6/fixed-width table abbreviations, narrower function-block operand widths, the interning caches (`scalar_types`, `small_words`, `dx_ops`), and the scalar-width queries in `ops.rs`/`shader.rs`/`lower*.rs`. CONTRIBUTING asks a PR over ~800 lines to say why it cannot be split, and the description does not. Each of these parts builds and can be checked on its own. Splitting would also let a bisect find which encoding change a driver objects to. - **Semantic conflict with #3655, not only a textual one.** `live_types` (`module.rs` ~1336) marks types only from entry-body instructions in `order`, and `val_rel_w`/`bb_w` come from the entry body only. #3655 writes internal helper bodies from `body.instructions` with raw `inst.ty.0` type IDs (#3655 `module.rs` ~1289). After both merge, a type that only a helper uses either hits `expect("use of a dropped type")` or is written with an unremapped ID. #3654 (stacked on this PR) already extends `mark_inst` and `max_inst_id` to cover its helper bodies. Whichever of #3645/#3655 lands second has to make the same change for #3655's bodies. - **Measured-impact claims are not this tree's.** The per-pass byte and p50 savings come from a separate sweep branch ("Not tested" says so). The -2244 MB peak commit comes from a single smoke pair, and a bitcode reduction of about 0.8 MB over 329 shaders cannot explain it. Please present the smoke numbers as a regression check only, or show where the memory goes. - **On by default, one vendor.** Every direct-DXIL shader now gets the new type numbering, constant order and abbreviations, with no switch. Validation and the smoke run were done on NVIDIA only. The encodings are standard LLVM bitstream features, but AMD's DXIL reader has not run them. The tests round-trip only through the in-repo `bitreader_tests` reader, written alongside the writer, and the DXC-validation tests SKIP without DXC. Fine (by reading): the Char6 table and Array/Char6 abbrev encoding match LLVM. Every Fixed width covers its maximum value: `ty_w`, `sym_w`, `md_idx_w`, `val_w`, `bb_w`, and `val_rel_w` for callee and GEP pointer relative IDs. The paramattr index (≤4) and linkage (0/3) fit their fixed fields. Each block has at most 4 user abbrevs at width 3 (settype falls back to an unabbreviated record when 4 are in use). The pruned type table keeps children before parents. Constant regrouping by (depth, type) keeps aggregate elements first, and every reference goes through `cmap`/`tmap`. `declarations()` copies `small_words` together with `consts`, and the `dx_ops` cache rechecks name, suffix, return and parameter types. `compute_omits_rodata_without_s_getpc` still asserts the same thing, now with a live use. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Gevroska commented 2026-12-02 11:11:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Gevroska on 2026-12-02T11:11:03Z.


merge-check
base: 1c8b551475
head: bc47921593
merge: clean (ebcf2ebae328459870a0dc4205d76b10ee022296)
build: cargo build --workspace passed. Release builds of base and merge also passed.

tests: All 13 focused DXIL checks passed on my RTX 3080 with zero skips. The full four-thread workspace suite finished with 2,916 passed, 1 failed and 51 ignored. It also logged 28 runtime skips and 10 optional sample notices.

The failure was in retained_failed_demand_observes_another_binds_successful_retry. Its retry assertions passed, but the final fake-PSO reference count was (0, 1) instead of (0, 0). That test is unchanged. On each revision it passed five isolated runs and three four-thread runs of its test group. I couldn’t reproduce the full-suite failure in those controls.

review: DXC accepted the aggregate compute fixture and branchy graphics shaders. GPU readback matched the expected pixels with direct DXIL, HLSL, and both mixed vertex/pixel combinations. Compact and plain compute shaders also produced the expected results, including the inline literal table case. The full suite passed the automatic compact-table test above 16,384 entries. This adds NVIDIA Ampere coverage.

performance: I ran two pairs of 60-second offline startups with fresh XCL caches and the shared NVIDIA driver cache. With base first, base recorded 1,219 PresentX and merge recorded 848 (69.57% of base, below the 80% threshold). With the order reversed, merge recorded 900 and base recorded 982 (91.65%, above threshold). All four runs exited cleanly with zero crashes or device removals. Base built 4,101 pipelines in each run, while merge built 1,453 and 2,124. The merge presented fewer frames in both orders, but the startup workloads differed and driver-cache warmth was uncontrolled. I can’t attribute the gap to bitcode compaction from these runs.

verdict: not yet. The focused correctness checks passed. The full-suite failure remains unresolved, and only one of the two startup pairs met the frame threshold.

hardware / tool and model: NVIDIA RTX 3080, driver 32.0.16.1692, Ryzen 7 5700X, Windows 11 25H2 build 26200.9457, Rust 1.100.0 MSVC, DXC 1.9.2609.5. OpenAI Codex GPT-6.2 Sol ran the tests. Independent Codex agents using the same model reviewed the source and verified the results. GPT-6.2 Astra drafted this comment.

I reviewed and approved this comment before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7343545907 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#issuecomment-7343545907). Originally posted by [Gevroska](https://github.com/Gevroska) on 2026-12-02T11:11:03Z. --- merge-check base: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f head: bc47921593dd57fb16cb30bad78c4a256f7640a7 merge: clean (ebcf2ebae328459870a0dc4205d76b10ee022296) build: cargo build --workspace passed. Release builds of base and merge also passed. tests: All 13 focused DXIL checks passed on my RTX 3080 with zero skips. The full four-thread workspace suite finished with 2,916 passed, 1 failed and 51 ignored. It also logged 28 runtime skips and 10 optional sample notices. The failure was in retained_failed_demand_observes_another_binds_successful_retry. Its retry assertions passed, but the final fake-PSO reference count was (0, 1) instead of (0, 0). That test is unchanged. On each revision it passed five isolated runs and three four-thread runs of its test group. I couldn’t reproduce the full-suite failure in those controls. review: DXC accepted the aggregate compute fixture and branchy graphics shaders. GPU readback matched the expected pixels with direct DXIL, HLSL, and both mixed vertex/pixel combinations. Compact and plain compute shaders also produced the expected results, including the inline literal table case. The full suite passed the automatic compact-table test above 16,384 entries. This adds NVIDIA Ampere coverage. performance: I ran two pairs of 60-second offline startups with fresh XCL caches and the shared NVIDIA driver cache. With base first, base recorded 1,219 PresentX and merge recorded 848 (69.57% of base, below the 80% threshold). With the order reversed, merge recorded 900 and base recorded 982 (91.65%, above threshold). All four runs exited cleanly with zero crashes or device removals. Base built 4,101 pipelines in each run, while merge built 1,453 and 2,124. The merge presented fewer frames in both orders, but the startup workloads differed and driver-cache warmth was uncontrolled. I can’t attribute the gap to bitcode compaction from these runs. verdict: not yet. The focused correctness checks passed. The full-suite failure remains unresolved, and only one of the two startup pairs met the frame threshold. hardware / tool and model: NVIDIA RTX 3080, driver 32.0.16.1692, Ryzen 7 5700X, Windows 11 25H2 build 26200.9457, Rust 1.100.0 MSVC, DXC 1.9.2609.5. OpenAI Codex GPT-6.2 Sol ran the tests. Independent Codex agents using the same model reviewed the source and verified the results. GPT-6.2 Astra drafted this comment. I reviewed and approved this comment before posting.
Foniass commented 2026-12-02 11:50:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T11:50:37Z.


merge-check
base: 1c8b551475
head: bc47921593
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2917 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read by one reviewer at this same head; the review is at https://github.com/xcl-dev/xcl/pull/3645#issuecomment-7340204231 and its findings stand. Most serious: 865 lines and 5 changes in one commit with no reason given for not splitting (no bitcode bug found).
performance: 60 s smoke of a retail title, main 1c8b5514 vs this merge (bc479215): 1652 -> 1437 frames shown (86 %; last presents per 2 s: 60 60 60), peak commit 18228 -> 15666 MB, 0 device removals, 0 crashes. This run is lower than most today: the PC was in use at the time (a browser and Discord running), and main's own runs on this machine today ranged from 1370 to 1652 frames, so the difference isn't clearly from this PR.
verdict: not yet: 865 lines and 5 changes in one commit with no reason given for not splitting (no bitcode bug found) (see the review)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7344482928 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#issuecomment-7344482928). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T11:50:37Z. --- merge-check base: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f head: bc47921593dd57fb16cb30bad78c4a256f7640a7 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2917 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none review: read by one reviewer at this same head; the review is at https://github.com/xcl-dev/xcl/pull/3645#issuecomment-7340204231 and its findings stand. Most serious: 865 lines and 5 changes in one commit with no reason given for not splitting (no bitcode bug found). performance: 60 s smoke of a retail title, main 1c8b5514 vs this merge (bc479215): 1652 -> 1437 frames shown (86 %; last presents per 2 s: 60 60 60), peak commit 18228 -> 15666 MB, 0 device removals, 0 crashes. This run is lower than most today: the PC was in use at the time (a browser and Discord running), and main's own runs on this machine today ranged from 1370 to 1652 frames, so the difference isn't clearly from this PR. verdict: not yet: 865 lines and 5 changes in one commit with no reason given for not splitting (no bitcode bug found) (see the review) hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 AI-written and posted by Foniass without a human check of each point.
Kalmarv commented 2026-12-02 15:07:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T15:07:19Z.


Thanks @Foniass and @Gevroska for the detailed reviews and checks. Rebased onto current main (5eaadb54c, which includes #3655) and updated to head 0cd5086ff:

  • Fixed the #3655 HelperBody semantic conflict (@Foniass): live_types and write_inst now walk live helper bodies using helper-local SSA types (helper_local_types), max_inst_id/max_blocks include live helper bodies so val_rel_w and bb_w cover helper blocks and call relative IDs, and MODULE_CODE_FUNCTION emits proto and LINKAGE_INTERNAL through the abbreviated function record. Added helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths (fails if helper-only i16 is pruned or if bb_w/val_rel_w come from the entry body alone) and spin_wait_and_barrier_arrive_helpers_validate_with_compacted_bitcode (validates #3655's xcl.spin.wait and xcl.barrier.arrive with DXC 1.9.2609.5).
  • Scope/size & honest claims (@Foniass): Updated the PR description to explain why the PR is kept together (+563/-172 production code + +293 tests, with dead-type pruning determining the live ty_w used across the table abbreviations), removed separate-branch sweep claims as measurements of this commit, framed the 60 s smoke pair strictly as a regression check, and noted AMD/Intel drivers remain untested.
  • Cold-cache startup frame drop (@Gevroska): Confirmed the first run after changing gpu/dxil/*.rs and emitted bitcode bytes compiles startup pipelines cold (1303 frames here, 0 removals, 0 crashes), while the warm run matches main (1694 vs 1685 frames shown, 61 60 60 presents per 2 s, 15199 vs 16337 MB peak commit, 0 removals, 0 crashes).

Verification on 0cd5086ff (RTX 5070 Ti, driver 610.74, Ryzen 9 9950X, Windows 11 26200, rustc 1.99.0, DXC 1.9.2609.5):

  • cargo build --release -p xcl: ok (39 warnings; 0 new vs main).
  • scripts/test.ps1 (with DXC 1.9.2609.5): 2984 passed, 0 failed, 52 ignored across 43 test targets (24 SKIPPED GPU tests: 22 no wave64, 2 no heap windows; 0 DXC skips).
  • python scripts/pr_check.py --local: description ok.

AI use: Antigravity (Gemini 4 Neon) rebased #3645, implemented the #3655 HelperBody fix and tests, ran the verification suite and smoke pair, and drafted this reply.

<!-- greyfinch-sync:ivall/xcl:comment:7349758963 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#issuecomment-7349758963). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T15:07:19Z. --- Thanks @Foniass and @Gevroska for the detailed reviews and checks. Rebased onto current `main` (`5eaadb54c`, which includes `#3655`) and updated to head `0cd5086ff`: - **Fixed the `#3655` `HelperBody` semantic conflict (@Foniass):** `live_types` and `write_inst` now walk live helper bodies using helper-local SSA types (`helper_local_types`), `max_inst_id`/`max_blocks` include live helper bodies so `val_rel_w` and `bb_w` cover helper blocks and call relative IDs, and `MODULE_CODE_FUNCTION` emits `proto` and `LINKAGE_INTERNAL` through the abbreviated function record. Added `helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths` (fails if helper-only `i16` is pruned or if `bb_w`/`val_rel_w` come from the entry body alone) and `spin_wait_and_barrier_arrive_helpers_validate_with_compacted_bitcode` (validates `#3655`'s `xcl.spin.wait` and `xcl.barrier.arrive` with DXC `1.9.2609.5`). - **Scope/size & honest claims (@Foniass):** Updated the PR description to explain why the PR is kept together (`+563/-172` production code + `+293` tests, with dead-type pruning determining the live `ty_w` used across the table abbreviations), removed separate-branch sweep claims as measurements of this commit, framed the 60 s smoke pair strictly as a regression check, and noted AMD/Intel drivers remain untested. - **Cold-cache startup frame drop (@Gevroska):** Confirmed the first run after changing `gpu/dxil/*.rs` and emitted bitcode bytes compiles startup pipelines cold (1303 frames here, 0 removals, 0 crashes), while the warm run matches `main` (`1694` vs `1685` frames shown, `61 60 60` presents per 2 s, `15199` vs `16337 MB` peak commit, 0 removals, 0 crashes). Verification on `0cd5086ff` (RTX 5070 Ti, driver 610.74, Ryzen 9 9950X, Windows 11 26200, `rustc 1.99.0`, DXC `1.9.2609.5`): - `cargo build --release -p xcl`: ok (39 warnings; 0 new vs `main`). - `scripts/test.ps1` (with DXC `1.9.2609.5`): **2984 passed, 0 failed, 52 ignored** across 43 test targets (24 `SKIPPED` GPU tests: 22 `no wave64`, 2 `no heap windows`; 0 DXC skips). - `python scripts/pr_check.py --local`: `description ok`. AI use: Antigravity (`Gemini 4 Neon`) rebased `#3645`, implemented the `#3655` `HelperBody` fix and tests, ran the verification suite and smoke pair, and drafted this reply.
bmjask commented 2026-12-02 18:00:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T18:00:27Z.

Review: COMMENTED


Review of 0cd5086f: 2 finding(s) (2 medium), most severe first.

  1. Medium crates/xcl/src/gpu/dxil/module.rs:1935: see below.
  2. Medium crates/xcl/src/gpu/dxil/bitstream.rs:60: see below.

On lines outside the diff:

  1. Medium crates/xcl/src/gpu/dxil/module.rs:1935: Not certain about this one: the PR removed the write_bitcode loop that interned Ptr(func_ty, 0) for every function, but value_ty still indexes type_ids[&TypeDef::Ptr(..)] for Value::Func, and its comment still says the pointer types already exist. So the writer's val_ty calls (Gep base, Alloca size, Switch operand, live_types) can hit a missing key and panic in try_to_bitcode, which is meant to return builder errors as Err. A function value from func_value() that never went through type_of/md_value reaching such a path would panic while writing. declare_dx_op already special-cases Value::Func (~568) for this. Interning the pointer type lazily in value_ty would make it safe.

  2. Medium crates/xcl/src/gpu/dxil/bitstream.rs:60: Not certain about this one: many self-describing VBR/unabbreviated fields become Fixed(w) abbreviation fields, but emit only checks that a value fits its width with debug_assert!, so an oversized value silently corrupts the bitstream in release builds. If FnAttrs::index() ever goes past 7, MODULE_CODE_FUNCTION (Fixed(3), module.rs:1294) truncates it. A bad aggregate element (an Inst value with abs >= inst_base) overflows ArrayFixed(val_w) at module.rs:1316. In both cases value << nbits ORs bits into the next fields, giving garbage DXIL that fails only at DXC validation or PSO creation rather than as a clear builder error. Making the check a real one (returning Err) would keep the old fail-safe behaviour.


These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

<!-- greyfinch-sync:ivall/xcl:review:6156091915 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#pullrequestreview-6156091915). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T18:00:27Z. **Review:** COMMENTED --- Review of `0cd5086f`: 2 finding(s) (2 medium), most severe first. 1. **Medium** `crates/xcl/src/gpu/dxil/module.rs:1935`: see below. 2. **Medium** `crates/xcl/src/gpu/dxil/bitstream.rs:60`: see below. **On lines outside the diff:** 1. **Medium** `crates/xcl/src/gpu/dxil/module.rs:1935`: Not certain about this one: the PR removed the `write_bitcode` loop that interned `Ptr(func_ty, 0)` for every function, but `value_ty` still indexes `type_ids[&TypeDef::Ptr(..)]` for `Value::Func`, and its comment still says the pointer types already exist. So the writer's `val_ty` calls (Gep base, Alloca size, Switch operand, `live_types`) can hit a missing key and panic in `try_to_bitcode`, which is meant to return builder errors as Err. A function value from `func_value()` that never went through `type_of`/`md_value` reaching such a path would panic while writing. `declare_dx_op` already special-cases `Value::Func` (~568) for this. Interning the pointer type lazily in `value_ty` would make it safe. 2. **Medium** `crates/xcl/src/gpu/dxil/bitstream.rs:60`: Not certain about this one: many self-describing VBR/unabbreviated fields become Fixed(w) abbreviation fields, but `emit` only checks that a value fits its width with `debug_assert!`, so an oversized value silently corrupts the bitstream in release builds. If `FnAttrs::index()` ever goes past 7, MODULE_CODE_FUNCTION (Fixed(3), module.rs:1294) truncates it. A bad aggregate element (an Inst value with abs >= inst_base) overflows `ArrayFixed(val_w)` at module.rs:1316. In both cases `value << nbits` ORs bits into the next fields, giving garbage DXIL that fails only at DXC validation or PSO creation rather than as a clear builder error. Making the check a real one (returning Err) would keep the old fail-safe behaviour. --- _These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it._
bmjask commented 2026-12-02 18:00:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T18:00:30Z.


@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.

<!-- greyfinch-sync:ivall/xcl:comment:7353855095 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#issuecomment-7353855095). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T18:00:30Z. --- @Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
Foniass commented 2026-12-02 18:08:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T18:08:10Z.


merge-check
base: 5eaadb54c1
head: 0cd5086ff8
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2984 passed, 0 failed, 52 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: follow-up on 0cd5086f (since bc479215, my last review's head). The PR still compacts direct-DXIL bitcode: dead-type pruning, constants grouped by type, Char6 and fitted-width abbreviations, interning caches, width queries. It is now rebased onto the merged #3655, and its helper bodies are walked for types and widths. This changes every direct-DXIL shader's bitcode by default, with no switch. The build.rs source hash invalidates caches automatically. Findings: (1) Semantic conflict with #3655: fixed. live_types marks helper-local types (helper_local_types, module.rs ~1601–1620). max_inst_id/max_blocks include helper bodies (~1216–1223), and write_inst gets helper types (~1466–1478). helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths (~2658) fails without the fix. (2) Size and scope: partly addressed, and bigger. It is now 1028 changed lines (was 865). The new "why one PR" paragraph only ties pruning to Fixed(ty_w). The interning caches (scalar_types, small_words, dx_ops), the int_width/float_width queries and the Char6 abbreviations do not depend on pruning and could each be a separate PR. (3) Measured-impact claims: fixed. The sweep numbers are gone, and the smoke pair is presented as a regression check only. (4) On by default, tested on one vendor: open. Every shader's bitcode changes. Tests are bitreader round-trips plus DXC validation, which skips without DXC. GPU runs exist only on NVIDIA, and AMD's driver has never parsed these encodings. (5) New: semantic conflict with #3707. git merge-tree is clean, but #3707 calls inline_helpers() before write_bitcode. This PR's helper test (fn_recs.len() == 3, func_blocks.len() == 2) would then fail, and its helper-body paths become dead code. (6) New: conflicts with #3654 in 3 hunks of module.rs (FuncAbbrevs::define against #3654's shared BLOCKINFO abbreviations, the helper-block abbreviation, the tests). It is semantic too: #3654's Op::CallOutput writes a raw inst.ty.0, which mark_inst here ignores (_ => {}), so after pruning the type ID would be wrong. Fine: the Char6 define/emit/decode matches LLVM 3.7. Every Fixed width covers its maximum, including widths derived from helpers. The GLOBALVAR/FUNCTION abbreviation operand counts are correct. There are at most 4 abbreviations per block at width 3. The caches cannot go stale (append-only). The dx_ops cache rechecks the full signature. The constant depth sort is sound. The removed function-pointer type prepass is not needed on the write path.
performance: 60 s smoke of a retail title, main 5eaadb54 vs this merge (0cd5086f): 1422 -> 1580 frames shown (111 %; last presents per 2 s: 60 60 60), peak commit 17184 -> 15505 MB, 0 device removals, 0 crashes.
verdict: not yet: 1028 changed lines in one commit with a reason that only covers pruning plus ty_w (the interning caches, width queries and Char6 abbreviations could each be a separate PR), on by default for every shader with GPU runs on NVIDIA only. (see the review)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7353989351 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#issuecomment-7353989351). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T18:08:10Z. --- merge-check base: 5eaadb54c14e0fc29597b2a1689d7dbd83491303 head: 0cd5086ff84f915f13672342715461e3bbf36e8a merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2984 passed, 0 failed, 52 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none review: follow-up on 0cd5086f (since bc479215, my last review's head). The PR still compacts direct-DXIL bitcode: dead-type pruning, constants grouped by type, Char6 and fitted-width abbreviations, interning caches, width queries. It is now rebased onto the merged #3655, and its helper bodies are walked for types and widths. This changes every direct-DXIL shader's bitcode by default, with no switch. The `build.rs` source hash invalidates caches automatically. Findings: (1) **Semantic conflict with #3655: fixed.** `live_types` marks helper-local types (`helper_local_types`, module.rs ~1601–1620). `max_inst_id`/`max_blocks` include helper bodies (~1216–1223), and `write_inst` gets helper types (~1466–1478). `helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths` (~2658) fails without the fix. (2) **Size and scope: partly addressed, and bigger.** It is now 1028 changed lines (was 865). The new "why one PR" paragraph only ties pruning to `Fixed(ty_w)`. The interning caches (`scalar_types`, `small_words`, `dx_ops`), the `int_width`/`float_width` queries and the Char6 abbreviations do not depend on pruning and could each be a separate PR. (3) **Measured-impact claims: fixed.** The sweep numbers are gone, and the smoke pair is presented as a regression check only. (4) **On by default, tested on one vendor: open.** Every shader's bitcode changes. Tests are bitreader round-trips plus DXC validation, which skips without DXC. GPU runs exist only on NVIDIA, and AMD's driver has never parsed these encodings. (5) **New: semantic conflict with #3707.** `git merge-tree` is clean, but #3707 calls `inline_helpers()` before `write_bitcode`. This PR's helper test (`fn_recs.len() == 3`, `func_blocks.len() == 2`) would then fail, and its helper-body paths become dead code. (6) **New: conflicts with #3654 in 3 hunks of `module.rs`** (`FuncAbbrevs::define` against #3654's shared BLOCKINFO abbreviations, the helper-block abbreviation, the tests). It is semantic too: #3654's `Op::CallOutput` writes a raw `inst.ty.0`, which `mark_inst` here ignores (`_ => {}`), so after pruning the type ID would be wrong. Fine: the Char6 define/emit/decode matches LLVM 3.7. Every Fixed width covers its maximum, including widths derived from helpers. The GLOBALVAR/FUNCTION abbreviation operand counts are correct. There are at most 4 abbreviations per block at width 3. The caches cannot go stale (append-only). The `dx_ops` cache rechecks the full signature. The constant depth sort is sound. The removed function-pointer type prepass is not needed on the write path. performance: 60 s smoke of a retail title, main 5eaadb54 vs this merge (0cd5086f): 1422 -> 1580 frames shown (111 %; last presents per 2 s: 60 60 60), peak commit 17184 -> 15505 MB, 0 device removals, 0 crashes. verdict: not yet: 1028 changed lines in one commit with a reason that only covers pruning plus `ty_w` (the interning caches, width queries and Char6 abbreviations could each be a separate PR), on by default for every shader with GPU runs on NVIDIA only. (see the review) hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 AI-written and posted by Foniass without a human check of each point.
Kalmarv commented 2026-12-02 18:16:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T18:16:59Z.


Thanks @bmjask for the two findings and @Foniass for the follow-up merge-check! Both of @bmjask's findings were valid edge cases and are now fixed in 253c0271a:

  1. Value::Func pointer-type interning (module.rs): Added ensure_func_ptr_types right before live_types in write_bitcode so Ptr(f.ty, 0) is lazily interned for any function actually referenced as a live Value::Func operand (while ordinary Op::Call callees still do not intern dead pointer types), and switched read-only scans (declare_dx_op, zero_extended_bit, uses_double_extensions, insts_use_type, live_feature_scan) to try_value_ty so an un-interned Value::Func can never panic. Covered by func_value_operand_interns_pointer_type_without_panicking.
  2. Runtime fixed-field width checks (bitstream.rs, module.rs): Replaced debug_assert! width/abbrev-id checks in BitWriter::emit and define_abbrev (plus ArrayChar6 lookup) with runtime error recording surfaced via BitWriter::try_finish -> Module::try_to_bitcode, and derived MODULE_CODE_FUNCTION's attribute width from FnAttrs::MAX_INDEX. Covered by fixed_field_overflow_returns_error_instead_of_corrupting_stream and aggregate_constant_with_inst_operand_returns_bitstream_error.

Regarding @Foniass's notes for @Prime1997:

  • Kept as one commit (+679/-190 production, +379/-2 tests) for review; happy to split out the interning caches / width queries / Char6 abbreviations if @Prime1997 prefers.
  • Noted the #3654 (Op::CallOutput type remapping) and #3707 (inline_helpers) interactions — #3654 is currently rebased independently on main, and whichever lands second will adapt.

Verification on 253c0271a (RTX 5070 Ti, driver 610.74, DXC 1.9.2609.5):

  • cargo build --release -p xcl: clean, 39 warnings (0 new vs main 5eaadb54c).
  • scripts/test.ps1: 2987 passed, 0 failed, 52 ignored across 43 targets (24 SKIPPED GPU tests: 22 no wave64, 2 no heap windows; 0 DXC skips; cargo bench -p xcl --bench '*' -- --test passed).
  • 60 s scripts/smoke.ps1 pair (title: ea3b5e4d): main 5eaadb54c 1684 frames (0 removals, 0 crashes, 17495 MB) vs 253c0271a 1680 frames (0 removals, 0 crashes, 16364 MB; second 60 s run: 1636 frames, 0 removals, 0 crashes, 16147 MB).
  • python -X utf8 scripts/pr_check.py --local: description ok.

(Updated by Antigravity, Gemini 4 Neon.)

<!-- greyfinch-sync:ivall/xcl:comment:7354285583 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#issuecomment-7354285583). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T18:16:59Z. --- Thanks `@bmjask` for the two findings and `@Foniass` for the follow-up `merge-check`! Both of `@bmjask`'s findings were valid edge cases and are now fixed in `253c0271a`: 1. **`Value::Func` pointer-type interning (`module.rs`):** Added `ensure_func_ptr_types` right before `live_types` in `write_bitcode` so `Ptr(f.ty, 0)` is lazily interned for any function actually referenced as a live `Value::Func` operand (while ordinary `Op::Call` callees still do not intern dead pointer types), and switched read-only scans (`declare_dx_op`, `zero_extended_bit`, `uses_double_extensions`, `insts_use_type`, `live_feature_scan`) to `try_value_ty` so an un-interned `Value::Func` can never panic. Covered by `func_value_operand_interns_pointer_type_without_panicking`. 2. **Runtime fixed-field width checks (`bitstream.rs`, `module.rs`):** Replaced `debug_assert!` width/abbrev-id checks in `BitWriter::emit` and `define_abbrev` (plus `ArrayChar6` lookup) with runtime error recording surfaced via `BitWriter::try_finish` -> `Module::try_to_bitcode`, and derived `MODULE_CODE_FUNCTION`'s attribute width from `FnAttrs::MAX_INDEX`. Covered by `fixed_field_overflow_returns_error_instead_of_corrupting_stream` and `aggregate_constant_with_inst_operand_returns_bitstream_error`. Regarding `@Foniass`'s notes for `@Prime1997`: - Kept as one commit (`+679/-190` production, `+379/-2` tests) for review; happy to split out the interning caches / width queries / Char6 abbreviations if `@Prime1997` prefers. - Noted the `#3654` (`Op::CallOutput` type remapping) and `#3707` (`inline_helpers`) interactions — `#3654` is currently rebased independently on `main`, and whichever lands second will adapt. Verification on `253c0271a` (RTX 5070 Ti, driver 610.74, DXC `1.9.2609.5`): - `cargo build --release -p xcl`: clean, 39 warnings (0 new vs `main` `5eaadb54c`). - `scripts/test.ps1`: **2987 passed, 0 failed, 52 ignored** across 43 targets (24 `SKIPPED` GPU tests: 22 `no wave64`, 2 `no heap windows`; 0 DXC skips; `cargo bench -p xcl --bench '*' -- --test` passed). - 60 s `scripts/smoke.ps1` pair (`title: ea3b5e4d`): `main` `5eaadb54c` 1684 frames (0 removals, 0 crashes, 17495 MB) vs `253c0271a` 1680 frames (0 removals, 0 crashes, 16364 MB; second 60 s run: 1636 frames, 0 removals, 0 crashes, 16147 MB). - `python -X utf8 scripts/pr_check.py --local`: `description ok`. *(Updated by Antigravity, Gemini 4 Neon.)*
bmjask commented 2026-12-02 18:26:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T18:26:42Z.

Review: COMMENTED


Review of 253c0271: 1 finding(s) (1 medium), most severe first.

Re-review at 253c0271. The silent bitstream corruption from debug_assert!-only width checks looks addressed: the writer now has an error path. The Value::Func pointer-type panic is fixed for the bitcode writer (ensure_func_ptr_types), but the same panic is still reachable earlier, from optimize() (below).

  1. Medium crates/xcl/src/gpu/dxil/module/opt.rs:518: see below.

On lines outside the diff:

  1. Medium crates/xcl/src/gpu/dxil/module/opt.rs:518: The PR says read-only scans are guarded with try_value_ty, but optimize() still calls the panicking value_ty on every operand: in removable() here, and at opt.rs 136/188/192/417/446/487/494/928/1054/1063/1082. ensure_func_ptr_types runs only later, inside write_bitcode. So a module that does what the new test func_value_operand_interns_pointer_type_without_panicking does (m.switch(m.func_value(callee), ..), or a call taking func_value(f) as an argument) and then goes through the normal Shader::try_finish/kernel path panics in the DCE loop (opt.rs:1454) with "function pointer type not interned". The test passes only because it skips optimize(). Interning Ptr(f.ty, 0) in func_value, or putting back the eager interning loop (live_types now drops unused types anyway), would close every path.

These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

<!-- greyfinch-sync:ivall/xcl:review:6156470752 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#pullrequestreview-6156470752). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T18:26:42Z. **Review:** COMMENTED --- Review of `253c0271`: 1 finding(s) (1 medium), most severe first. Re-review at `253c0271`. The silent bitstream corruption from `debug_assert!`-only width checks looks addressed: the writer now has an error path. The `Value::Func` pointer-type panic is fixed for the bitcode writer (`ensure_func_ptr_types`), but the same panic is still reachable earlier, from `optimize()` (below). 1. **Medium** `crates/xcl/src/gpu/dxil/module/opt.rs:518`: see below. **On lines outside the diff:** 1. **Medium** `crates/xcl/src/gpu/dxil/module/opt.rs:518`: The PR says read-only scans are guarded with `try_value_ty`, but `optimize()` still calls the panicking `value_ty` on every operand: in `removable()` here, and at opt.rs 136/188/192/417/446/487/494/928/1054/1063/1082. `ensure_func_ptr_types` runs only later, inside `write_bitcode`. So a module that does what the new test `func_value_operand_interns_pointer_type_without_panicking` does (`m.switch(m.func_value(callee), ..)`, or a call taking `func_value(f)` as an argument) and then goes through the normal `Shader::try_finish`/`kernel` path panics in the DCE loop (opt.rs:1454) with "function pointer type not interned". The test passes only because it skips `optimize()`. Interning `Ptr(f.ty, 0)` in `func_value`, or putting back the eager interning loop (`live_types` now drops unused types anyway), would close every path. --- _These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it._
Kalmarv commented 2026-12-02 18:48:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T18:48:34Z.


Good catch @bmjask — updated to c40ec9800 (and simplified the diff by ~70 lines):

  • Cached ptr: Ty on FuncDecl inside declare() (matching GlobalDef::ptr), so value_ty(&self, v: Value) is total and O(1) across optimize() (opt.rs), declare_dx_op, read-only scans, and write_bitcode, and removed ensure_func_ptr_types / try_value_ty. live_types still prunes unused function pointer types before emitting BLOCK_TYPE.
  • Updated the regression test to func_value_operand_survives_optimize_and_prunes_unused_func_ptrs, which runs m.optimize() followed by m.try_to_bitcode(...) and asserts only the referenced Value::Func's pointer type is emitted in BLOCK_TYPE.

Verification on c40ec9800 (RTX 5070 Ti, driver 610.74, DXC 1.9.2609.5):

  • cargo build --release -p xcl: clean, 39 warnings (0 new vs main 5eaadb54c).
  • scripts/test.ps1: 2987 passed, 0 failed, 52 ignored across 43 targets (24 SKIPPED GPU tests: 22 no wave64, 2 no heap windows; 0 DXC skips; cargo bench -p xcl --bench '*' -- --test passed).
  • 60 s scripts/smoke.ps1 pair (title: ea3b5e4d): main 5eaadb54c 1709 frames (0 removals, 0 crashes, 16892 MB) vs c40ec9800 warm 1710 frames (0 removals, 0 crashes, 15191 MB; initial cold-cache compile run: 1372 frames, 0 removals, 0 crashes, 15108 MB).
  • python -X utf8 scripts/pr_check.py --local: description ok.

(Updated by Antigravity, Gemini 4 Neon.)

<!-- greyfinch-sync:ivall/xcl:comment:7355185699 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#issuecomment-7355185699). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T18:48:34Z. --- Good catch `@bmjask` — updated to `c40ec9800` (and simplified the diff by ~70 lines): - Cached `ptr: Ty` on `FuncDecl` inside `declare()` (matching `GlobalDef::ptr`), so `value_ty(&self, v: Value)` is total and O(1) across `optimize()` (`opt.rs`), `declare_dx_op`, read-only scans, and `write_bitcode`, and removed `ensure_func_ptr_types` / `try_value_ty`. `live_types` still prunes unused function pointer types before emitting `BLOCK_TYPE`. - Updated the regression test to `func_value_operand_survives_optimize_and_prunes_unused_func_ptrs`, which runs `m.optimize()` followed by `m.try_to_bitcode(...)` and asserts only the referenced `Value::Func`'s pointer type is emitted in `BLOCK_TYPE`. Verification on `c40ec9800` (RTX 5070 Ti, driver 610.74, DXC `1.9.2609.5`): - `cargo build --release -p xcl`: clean, 39 warnings (0 new vs `main` `5eaadb54c`). - `scripts/test.ps1`: **2987 passed, 0 failed, 52 ignored** across 43 targets (24 `SKIPPED` GPU tests: 22 `no wave64`, 2 `no heap windows`; 0 DXC skips; `cargo bench -p xcl --bench '*' -- --test` passed). - 60 s `scripts/smoke.ps1` pair (`title: ea3b5e4d`): `main` `5eaadb54c` 1709 frames (0 removals, 0 crashes, 16892 MB) vs `c40ec9800` warm 1710 frames (0 removals, 0 crashes, 15191 MB; initial cold-cache compile run: 1372 frames, 0 removals, 0 crashes, 15108 MB). - `python -X utf8 scripts/pr_check.py --local`: `description ok`. *(Updated by Antigravity, Gemini 4 Neon.)*
bmjask commented 2026-12-02 18:58:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T18:58:44Z.

Review: COMMENTED


Review of c40ec980: 1 finding(s) (1 medium), most severe first.

Re-review at c40ec980. The Value::Func panic from optimize() reported on 253c0271 wasn't flagged again and looks addressed. The bad-aggregate-element case from the 0cd5086f review is only partly covered (below).

  1. Medium crates/xcl/src/gpu/dxil/module.rs:1299: An aggregate constant with a Value::Inst element is reported only when the instruction's id happens to overflow val_w. (inline)

These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

<!-- greyfinch-sync:ivall/xcl:review:6156961800 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#pullrequestreview-6156961800). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T18:58:44Z. **Review:** COMMENTED --- Review of `c40ec980`: 1 finding(s) (1 medium), most severe first. Re-review at `c40ec980`. The `Value::Func` panic from `optimize()` reported on `253c0271` wasn't flagged again and looks addressed. The bad-aggregate-element case from the `0cd5086f` review is only partly covered (below). 1. **Medium** `crates/xcl/src/gpu/dxil/module.rs:1299`: An aggregate constant with a `Value::Inst` element is reported only when the instruction's id happens to overflow `val_w`. (inline) --- _These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it._
bmjask commented 2026-12-02 18:58:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T18:58:45Z.

Code review location: crates/xcl/src/gpu/dxil/module.rs; line 1299

@@ -1154,68 +1241,101 @@ impl Module {
         }
         w.end_block();
 
-        self.write_types(&mut w);
-        w.record_str(MODULE_CODE_TRIPLE, &[], triple);
-        w.record_str(MODULE_CODE_DATALAYOUT, &[], datalayout);
-
-        for g in self.globals.iter().enumerate().filter(|(i, _)| gused[*i]).map(|x| x.1) {
-            // [valty, addrspace<<2 | explicit_type<<1 | isconst, initid+1, linkage, align, section,
-            //  visibility, tls, unnamed_addr, externally_initialized, dllstorage, comdat]
-            let init = g.init.map_or(0, |v| abs(v) + 1);
-            let linkage = if g.init.is_some() { LINKAGE_INTERNAL } else { LINKAGE_EXTERNAL };
-            let align = if g.align == 0 { 0 } else { g.align.trailing_zeros() as u64 + 1 };
-            w.record(
-                MODULE_CODE_GLOBALVAR,
-                &[g.ty.0 as u64, ((g.addrspace as u64) << 2) | 2 | g.constant as u64, init, linkage, align, 0, 0, 0, 0, 0, 0, 0],
-            );
+        let ty_w = bit_width(live_tys.len());
+        self.write_types(&mut w, &live_tys, tmap, ty_w);
+        let mut operands = Vec::new();
+        const STR_REC: &[AbbrevOp] = &[AbbrevOp::Fixed(2), AbbrevOp::ArrayFixed(8)];
+        let str_rec = w.define_abbrev(STR_REC);
+        for (code, s) in [(MODULE_CODE_TRIPLE, triple), (MODULE_CODE_DATALAYOUT, datalayout)] {
+            operands.clear();
+            operands.push(code as u64);
+            operands.extend(s.bytes().map(u64::from));
+            w.emit_abbrev(str_rec, STR_REC, &operands);
+        }
+
+        const Z: AbbrevOp = AbbrevOp::Literal(0);
+        if n_globals > 0 {
+            let global_ab = [
+                AbbrevOp::Literal(MODULE_CODE_GLOBALVAR as u64),
+                AbbrevOp::Fixed(ty_w),
+                AbbrevOp::Vbr(5),
+                AbbrevOp::Vbr(8),
+                AbbrevOp::Fixed(2),
+                AbbrevOp::Vbr(4),
+                Z, Z, Z, Z, Z, Z, Z,
+            ];
+            let ab = w.define_abbrev(&global_ab);
+            for g in self.globals.iter().enumerate().filter(|(i, _)| gused[*i]).map(|x| x.1) {
+                // [valty, addrspace<<2 | explicit_type<<1 | isconst, initid+1, linkage, align, section,
+                //  visibility, tls, unnamed_addr, externally_initialized, dllstorage, comdat]
+                let init = g.init.map_or(0, |v| abs(v) + 1);
+                let linkage = if g.init.is_some() { LINKAGE_INTERNAL } else { LINKAGE_EXTERNAL };
+                let align = if g.align == 0 { 0 } else { g.align.trailing_zeros() as u64 + 1 };
+                w.emit_abbrev(ab, &global_ab, &[ty_id(g.ty), ((g.addrspace as u64) << 2) | 2 | g.constant as u64, init, linkage, align]);
+            }
         }
+        // Only the type, prototype flag, linkage and parameter attributes vary.
+        let attr_w = bit_width_u64(FnAttrs::MAX_INDEX);
+        let function_ab = [
+            AbbrevOp::Literal(MODULE_CODE_FUNCTION as u64), AbbrevOp::Fixed(ty_w), Z,
+            AbbrevOp::Fixed(1), AbbrevOp::Fixed(2), AbbrevOp::Fixed(attr_w),
+            Z, Z, Z, Z, Z, Z, Z, Z, Z, Z,
+        ];
+        let function = w.define_abbrev(&function_ab);
         for f in self.funcs.iter().enumerate().filter(|(i, _)| fused[*i]).map(|x| x.1) {
             // [type, cc, isproto, linkage, paramattr, align, section, visibility,
             //  gc, unnamed_addr, prologue, dllstorage, comdat, prefix, personality]
             let proto = !f.defined && f.helper_body.is_none();
             let linkage = if f.helper_body.is_some() { LINKAGE_INTERNAL } else { LINKAGE_EXTERNAL };
-            w.record(
-                MODULE_CODE_FUNCTION,
-                &[f.ty.0 as u64, 0, proto as u64, linkage, f.attrs.index(), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
-            );
+            w.emit_abbrev(function, &function_ab, &[ty_id(f.ty), proto as u64, linkage, f.attrs.index()]);
         }
 
         // Module-level constants.
         if n_consts > 0 {
+            let has_int = const_order.iter().any(|&ci| matches!(self.consts[ci], ConstDef::Int(..)));
+            let has_f32 = const_order.iter().any(|&ci| matches!(self.consts[ci], ConstDef::Float(_, bits) if bits <= u32::MAX as u64));
+            let has_agg = const_order.iter().any(|&ci| matches!(self.consts[ci], ConstDef::Aggregate(..)));
+            let has_data = const_order.iter().any(|&ci| matches!(self.consts[ci], ConstDef::DataI32(..)));
+            let val_w = bit_width_u64(inst_base.saturating_sub(1));

Medium: An aggregate constant with a Value::Inst element is reported only when the instruction's id happens to overflow val_w. Nothing checks that aggregate elements are constants, so the 'error instead of corruption' path, and aggregate_constant_with_inst_operand_returns_bitstream_error, depend on how many instructions the module has. In a module with inst_base = 5 (val_w = 3), an aggregate referring to the first instruction (abs id 5 or 6, both under 8) fits Fixed(3). BitWriter records no error, and try_to_bitcode returns Ok with a CST_CODE_AGGREGATE pointing at an instruction-numbered value, which the LLVM reader or validator rejects or misreads. The test passes only because its 8 adds push the id past 2^val_w. Checking the elements in aggregate() (or in live_values) and calling fail would make it deterministic.

<!-- greyfinch-sync:ivall/xcl:review-comment:4774408585 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#discussion_r4774408585). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T18:58:45Z. **Code review location:** `crates/xcl/src/gpu/dxil/module.rs`; line 1299 ~~~~diff @@ -1154,68 +1241,101 @@ impl Module { } w.end_block(); - self.write_types(&mut w); - w.record_str(MODULE_CODE_TRIPLE, &[], triple); - w.record_str(MODULE_CODE_DATALAYOUT, &[], datalayout); - - for g in self.globals.iter().enumerate().filter(|(i, _)| gused[*i]).map(|x| x.1) { - // [valty, addrspace<<2 | explicit_type<<1 | isconst, initid+1, linkage, align, section, - // visibility, tls, unnamed_addr, externally_initialized, dllstorage, comdat] - let init = g.init.map_or(0, |v| abs(v) + 1); - let linkage = if g.init.is_some() { LINKAGE_INTERNAL } else { LINKAGE_EXTERNAL }; - let align = if g.align == 0 { 0 } else { g.align.trailing_zeros() as u64 + 1 }; - w.record( - MODULE_CODE_GLOBALVAR, - &[g.ty.0 as u64, ((g.addrspace as u64) << 2) | 2 | g.constant as u64, init, linkage, align, 0, 0, 0, 0, 0, 0, 0], - ); + let ty_w = bit_width(live_tys.len()); + self.write_types(&mut w, &live_tys, tmap, ty_w); + let mut operands = Vec::new(); + const STR_REC: &[AbbrevOp] = &[AbbrevOp::Fixed(2), AbbrevOp::ArrayFixed(8)]; + let str_rec = w.define_abbrev(STR_REC); + for (code, s) in [(MODULE_CODE_TRIPLE, triple), (MODULE_CODE_DATALAYOUT, datalayout)] { + operands.clear(); + operands.push(code as u64); + operands.extend(s.bytes().map(u64::from)); + w.emit_abbrev(str_rec, STR_REC, &operands); + } + + const Z: AbbrevOp = AbbrevOp::Literal(0); + if n_globals > 0 { + let global_ab = [ + AbbrevOp::Literal(MODULE_CODE_GLOBALVAR as u64), + AbbrevOp::Fixed(ty_w), + AbbrevOp::Vbr(5), + AbbrevOp::Vbr(8), + AbbrevOp::Fixed(2), + AbbrevOp::Vbr(4), + Z, Z, Z, Z, Z, Z, Z, + ]; + let ab = w.define_abbrev(&global_ab); + for g in self.globals.iter().enumerate().filter(|(i, _)| gused[*i]).map(|x| x.1) { + // [valty, addrspace<<2 | explicit_type<<1 | isconst, initid+1, linkage, align, section, + // visibility, tls, unnamed_addr, externally_initialized, dllstorage, comdat] + let init = g.init.map_or(0, |v| abs(v) + 1); + let linkage = if g.init.is_some() { LINKAGE_INTERNAL } else { LINKAGE_EXTERNAL }; + let align = if g.align == 0 { 0 } else { g.align.trailing_zeros() as u64 + 1 }; + w.emit_abbrev(ab, &global_ab, &[ty_id(g.ty), ((g.addrspace as u64) << 2) | 2 | g.constant as u64, init, linkage, align]); + } } + // Only the type, prototype flag, linkage and parameter attributes vary. + let attr_w = bit_width_u64(FnAttrs::MAX_INDEX); + let function_ab = [ + AbbrevOp::Literal(MODULE_CODE_FUNCTION as u64), AbbrevOp::Fixed(ty_w), Z, + AbbrevOp::Fixed(1), AbbrevOp::Fixed(2), AbbrevOp::Fixed(attr_w), + Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, + ]; + let function = w.define_abbrev(&function_ab); for f in self.funcs.iter().enumerate().filter(|(i, _)| fused[*i]).map(|x| x.1) { // [type, cc, isproto, linkage, paramattr, align, section, visibility, // gc, unnamed_addr, prologue, dllstorage, comdat, prefix, personality] let proto = !f.defined && f.helper_body.is_none(); let linkage = if f.helper_body.is_some() { LINKAGE_INTERNAL } else { LINKAGE_EXTERNAL }; - w.record( - MODULE_CODE_FUNCTION, - &[f.ty.0 as u64, 0, proto as u64, linkage, f.attrs.index(), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - ); + w.emit_abbrev(function, &function_ab, &[ty_id(f.ty), proto as u64, linkage, f.attrs.index()]); } // Module-level constants. if n_consts > 0 { + let has_int = const_order.iter().any(|&ci| matches!(self.consts[ci], ConstDef::Int(..))); + let has_f32 = const_order.iter().any(|&ci| matches!(self.consts[ci], ConstDef::Float(_, bits) if bits <= u32::MAX as u64)); + let has_agg = const_order.iter().any(|&ci| matches!(self.consts[ci], ConstDef::Aggregate(..))); + let has_data = const_order.iter().any(|&ci| matches!(self.consts[ci], ConstDef::DataI32(..))); + let val_w = bit_width_u64(inst_base.saturating_sub(1)); ~~~~ --- **Medium**: An aggregate constant with a `Value::Inst` element is reported only when the instruction's id happens to overflow `val_w`. Nothing checks that aggregate elements are constants, so the 'error instead of corruption' path, and `aggregate_constant_with_inst_operand_returns_bitstream_error`, depend on how many instructions the module has. In a module with inst_base = 5 (val_w = 3), an aggregate referring to the first instruction (abs id 5 or 6, both under 8) fits Fixed(3). BitWriter records no error, and `try_to_bitcode` returns Ok with a CST_CODE_AGGREGATE pointing at an instruction-numbered value, which the LLVM reader or validator rejects or misreads. The test passes only because its 8 adds push the id past 2^val_w. Checking the elements in `aggregate()` (or in `live_values`) and calling `fail` would make it deterministic.
Kalmarv commented 2026-12-02 19:19:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T19:19:38Z.


Good catch @bmjask — updated to 66afe7a64:

  • Module::aggregate() now checks elems directly and records a builder error (self.fail(...)) on any Value::Inst element, regardless of instruction count or val_w (while BitWriter::emit still catches any fixed-field overflow independently).
  • Updated the regression test to aggregate_constant_with_inst_operand_returns_error, using a single instruction whose absolute ID still fits Fixed(val_w).

Verification on 66afe7a64 (RTX 5070 Ti, driver 610.74, DXC 1.9.2609.5):

  • cargo build --release -p xcl: clean, 39 warnings (0 new vs main 5eaadb54c).
  • scripts/test.ps1: 2987 passed, 0 failed, 52 ignored across 43 targets (24 SKIPPED GPU tests: 22 no wave64, 2 no heap windows; 0 DXC skips; cargo bench -p xcl --bench '*' -- --test passed).
  • 60 s scripts/smoke.ps1 pair (title: ea3b5e4d): main 5eaadb54c 1700 frames (0 removals, 0 crashes, 16914 MB) vs 66afe7a64 1702 frames (0 removals, 0 crashes, 16118 MB; second 60 s run: 1707 frames, 0 removals, 0 crashes, 16300 MB).
  • python -X utf8 scripts/pr_check.py --local: description ok.

(Updated by Antigravity, Gemini 4 Neon.)

<!-- greyfinch-sync:ivall/xcl:comment:7355995840 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#issuecomment-7355995840). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T19:19:38Z. --- Good catch `@bmjask` — updated to `66afe7a64`: - `Module::aggregate()` now checks `elems` directly and records a builder error (`self.fail(...)`) on any `Value::Inst` element, regardless of instruction count or `val_w` (while `BitWriter::emit` still catches any fixed-field overflow independently). - Updated the regression test to `aggregate_constant_with_inst_operand_returns_error`, using a single instruction whose absolute ID still fits `Fixed(val_w)`. Verification on `66afe7a64` (RTX 5070 Ti, driver 610.74, DXC `1.9.2609.5`): - `cargo build --release -p xcl`: clean, 39 warnings (0 new vs `main` `5eaadb54c`). - `scripts/test.ps1`: **2987 passed, 0 failed, 52 ignored** across 43 targets (24 `SKIPPED` GPU tests: 22 `no wave64`, 2 `no heap windows`; 0 DXC skips; `cargo bench -p xcl --bench '*' -- --test` passed). - 60 s `scripts/smoke.ps1` pair (`title: ea3b5e4d`): `main` `5eaadb54c` 1700 frames (0 removals, 0 crashes, 16914 MB) vs `66afe7a64` 1702 frames (0 removals, 0 crashes, 16118 MB; second 60 s run: 1707 frames, 0 removals, 0 crashes, 16300 MB). - `python -X utf8 scripts/pr_check.py --local`: `description ok`. *(Updated by Antigravity, Gemini 4 Neon.)*
Gevroska commented 2026-12-02 23:27:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Gevroska on 2026-12-02T23:27:27Z.


I rechecked the four RTX 3080 startup logs from my earlier report on bc479215 (base 1c8b5514, tested merge ebcf2eba). I aligned each run at the end of the first sampling interval that recorded a presentation, then compared the next 52 seconds.

Launch order Merge presentation rate relative to base Time with at least one compute pipeline creation call in flight, base / merge
Base first 71.8% 0.43 s / 50.89 s
Merge first 91.7% 0.77 s / 50.81 s

Overlapping calls count once. One call on the base-first pair’s merge run had no recorded return. Even counting only calls that returned, the merge still covered 45.87 seconds of that window. The startup workloads differed and NVIDIA driver-cache warmth was uncontrolled, so these logs identify where to measure next. They don’t establish that bitcode compaction caused the gap.

Separately, I ran the standalone bitstream.rs tests on Windows. All 4 passed on 078358a0, and all 6 passed on 66afe7a6, including the Char6 and fixed-field error cases. That check was CPU-only. I don’t have a driver-timing comparison for 66afe7a6 yet.

AI disclosure: OpenAI Codex GPT-6.2 Sol handled the startup analysis, GPT-6.1 Terra ran the standalone writer tests, and GPT-6.2 Astra drafted this comment.

I reviewed and approved this comment before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7362019117 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#issuecomment-7362019117). Originally posted by [Gevroska](https://github.com/Gevroska) on 2026-12-02T23:27:27Z. --- I rechecked the four RTX 3080 startup logs from my earlier report on `bc479215` (base `1c8b5514`, tested merge `ebcf2eba`). I aligned each run at the end of the first sampling interval that recorded a presentation, then compared the next 52 seconds. | Launch order | Merge presentation rate relative to base | Time with at least one compute pipeline creation call in flight, base / merge | |---|---:|---:| | Base first | 71.8% | 0.43 s / 50.89 s | | Merge first | 91.7% | 0.77 s / 50.81 s | Overlapping calls count once. One call on the base-first pair’s merge run had no recorded return. Even counting only calls that returned, the merge still covered 45.87 seconds of that window. The startup workloads differed and NVIDIA driver-cache warmth was uncontrolled, so these logs identify where to measure next. They don’t establish that bitcode compaction caused the gap. Separately, I ran the standalone `bitstream.rs` tests on Windows. All 4 passed on `078358a0`, and all 6 passed on `66afe7a6`, including the Char6 and fixed-field error cases. That check was CPU-only. I don’t have a driver-timing comparison for `66afe7a6` yet. AI disclosure: OpenAI Codex GPT-6.2 Sol handled the startup analysis, GPT-6.1 Terra ran the standalone writer tests, and GPT-6.2 Astra drafted this comment. I reviewed and approved this comment before posting.
Kalmarv commented 2026-12-02 23:37:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T23:37:07Z.


Thanks @Gevroska for digging into the RTX 3080 logs and verifying the bitstream.rs tests on 66afe7a64.

That 0.43–0.77 s vs 50.8 s compute pipeline-creation in-flight gap matches what we saw on RTX 5070 Ti: because #3645 changes the emitted bitcode bytes of every direct-DXIL shader, the first run with #3645 misses the shared NVIDIA driver cache (even in merge-first order if main already has warm entries in the driver cache from prior runs on the machine). On RTX 5070 Ti, the first cold-cache run after changing the emitted bitcode recorded 1303 frames (0cd5086ff) / 1372 frames (c40ec9800) with 0 removals/crashes, and the subsequent warm runs with the compacted bitcode cached in the driver matched main (1702 / 1707 frames on 66afe7a64 vs 1700 on main, 60 60 60 presents per 2 s, 0 removals/crashes). A second run on the same merge head (or clearing the NVIDIA shader cache before both base and merge) should confirm whether any pipeline-creation gap remains once driver-cache warmth is matched.

(Drafted by Antigravity, Gemini 4 Neon.)

<!-- greyfinch-sync:ivall/xcl:comment:7362222030 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#issuecomment-7362222030). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T23:37:07Z. --- Thanks `@Gevroska` for digging into the RTX 3080 logs and verifying the `bitstream.rs` tests on `66afe7a64`. That `0.43–0.77 s` vs `50.8 s` compute pipeline-creation in-flight gap matches what we saw on RTX 5070 Ti: because `#3645` changes the emitted bitcode bytes of every direct-DXIL shader, the first run with `#3645` misses the shared NVIDIA driver cache (even in merge-first order if `main` already has warm entries in the driver cache from prior runs on the machine). On RTX 5070 Ti, the first cold-cache run after changing the emitted bitcode recorded 1303 frames (`0cd5086ff`) / 1372 frames (`c40ec9800`) with 0 removals/crashes, and the subsequent warm runs with the compacted bitcode cached in the driver matched `main` (`1702` / `1707` frames on `66afe7a64` vs `1700` on `main`, `60 60 60` presents per 2 s, 0 removals/crashes). A second run on the same merge head (or clearing the NVIDIA shader cache before both base and merge) should confirm whether any pipeline-creation gap remains once driver-cache warmth is matched. *(Drafted by Antigravity, Gemini 4 Neon.)*
Foniass commented 2026-12-03 00:52:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T00:52:54Z.


merge-check
base: 078358a058
head: 66afe7a64a
merge: clean
build: ok
tests: 3019 passed, 0 failed, 52 ignored; 28 skipped, the same as on main
review: 4 medium (below)
performance: 60 s smoke run: 1669 → 1516 frames (90 % of main), peak commit 17577 → 15435 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 220 s there, 0 device removals, 0 crashes, 2.4 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
verdict: safe to merge: no blocking finding (the points below are medium or nits), the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: Compacts direct-DXIL bitcode by default: dead-type pruning, constants grouped by type, Char6 and fitted-width abbreviations, interning caches, width queries. This follows up Foniass's merge-check on 0cd5086f. Since then it caches FuncDecl::ptr, turns BitWriter width overflows into errors (try_finish / try_to_bitcode) and rejects instructions inside aggregate constants, each with a test; reading found no bitcode bug. Still open from the last check: the size with a partial reason, on by default with NVIDIA-only runs, and the conflicts with #3707 and #3654.

Medium

  1. Size and scope still over the limit. One commit of +988/-200 (1188 changed lines, was 1028 at the last check) with five separable changes. The "why one PR" paragraph ties only dead-type pruning to ty_w; the interning caches (scalar_types, small_words, dx_ops), the int_width/float_width queries and the Char6 abbreviations do not depend on pruning and could each be their own PR. Earlier finding still open.
  2. On by default for every direct-DXIL shader, NVIDIA only. Every direct-DXIL shader's bitcode changes with no switch. GPU runs exist on NVIDIA only (RTX 5070 Ti, plus Gevroska's RTX 3080); AMD and Intel drivers have never parsed these encodings. Earlier finding still open.
  3. Semantic conflicts with #3707 and #3654. Still open at their current heads. #3707 (7b19e27d8) calls inline_helpers() before write_bitcode, so this PR's helper-body paths become dead and helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths (fn_recs.len() == 3, func_blocks.len() == 2) would fail after both merge. #3654 (29440ec74) conflicts textually in module.rs (git merge-tree), and its Op::CallOutput writes a raw inst.ty.0 that live_types does not mark. Whichever lands second has to adapt; the description should say so.
  4. Cold-start pipeline creation cost not explained. Gevroska's RTX 3080 logs show a compute pipeline creation call in flight for ~51 s of the first 52 s on the merge against <1 s on base. The author puts it down to a cold driver cache after any bitcode change (the warm runs match main), but nobody has compared cold against cold. A run with the driver cache cleared on both sides would settle whether the new encodings are slower for the driver to compile.
Checked and fine
  • Earlier finding fixed: the #3655 helper-body conflict (live_types, max_inst_id/max_blocks and write_inst cover live helper bodies, with a test that fails without it)
  • Earlier finding fixed: the measured-impact claims are gone; the smoke pairs are presented as regression checks only
  • The removed debug_asserts in bitstream.rs are replaced by runtime errors (width, abbrev id, Char6) surfaced through try_finish; production translation uses try_to_bitcode (graphics.rs ~1170), so a bad width fails the shader's translation and does not corrupt the stream or panic
  • FuncDecl::ptr is interned in declare(), so value_ty is total; unused function pointer types are still pruned (func_value_operand_survives_optimize_and_prunes_unused_func_ptrs)
  • Module::aggregate rejects Value::Inst elements whatever the module's instruction count (aggregate_constant_with_inst_operand_returns_error)
  • Every widened field (attr width from FnAttrs::MAX_INDEX, ty_w, val_w, bb_w, val_rel_w) is at least 1 bit, so emit never gets width 0
How this was tested
  • Merged onto main 078358a0, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 078358a0 and on this merge; presents per 2 s at the end: 60 60 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7363700836 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#issuecomment-7363700836). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T00:52:54Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: 66afe7a64a994b7ab215166403bd60cf70dae9f3 merge: clean build: ok tests: 3019 passed, 0 failed, 52 ignored; 28 skipped, the same as on main review: 4 medium (below) performance: 60 s smoke run: 1669 → 1516 frames (90 % of main), peak commit 17577 → 15435 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 220 s there, 0 device removals, 0 crashes, 2.4 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) verdict: safe to merge: no blocking finding (the points below are medium or nits), the suite passes and the smoke run is clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** Compacts direct-DXIL bitcode by default: dead-type pruning, constants grouped by type, Char6 and fitted-width abbreviations, interning caches, width queries. This follows up Foniass's merge-check on 0cd5086f. Since then it caches FuncDecl::ptr, turns BitWriter width overflows into errors (try_finish / try_to_bitcode) and rejects instructions inside aggregate constants, each with a test; reading found no bitcode bug. Still open from the last check: the size with a partial reason, on by default with NVIDIA-only runs, and the conflicts with #3707 and #3654. #### Medium 1. **Size and scope still over the limit.** One commit of +988/-200 (1188 changed lines, was 1028 at the last check) with five separable changes. The "why one PR" paragraph ties only dead-type pruning to ty_w; the interning caches (scalar_types, small_words, dx_ops), the int_width/float_width queries and the Char6 abbreviations do not depend on pruning and could each be their own PR. Earlier finding still open. 2. **On by default for every direct-DXIL shader, NVIDIA only.** Every direct-DXIL shader's bitcode changes with no switch. GPU runs exist on NVIDIA only (RTX 5070 Ti, plus Gevroska's RTX 3080); AMD and Intel drivers have never parsed these encodings. Earlier finding still open. 3. **Semantic conflicts with #3707 and #3654.** Still open at their current heads. #3707 (7b19e27d8) calls inline_helpers() before write_bitcode, so this PR's helper-body paths become dead and helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths (fn_recs.len() == 3, func_blocks.len() == 2) would fail after both merge. #3654 (29440ec74) conflicts textually in module.rs (git merge-tree), and its Op::CallOutput writes a raw inst.ty.0 that live_types does not mark. Whichever lands second has to adapt; the description should say so. 4. **Cold-start pipeline creation cost not explained.** Gevroska's RTX 3080 logs show a compute pipeline creation call in flight for ~51 s of the first 52 s on the merge against <1 s on base. The author puts it down to a cold driver cache after any bitcode change (the warm runs match main), but nobody has compared cold against cold. A run with the driver cache cleared on both sides would settle whether the new encodings are slower for the driver to compile. <details><summary>Checked and fine</summary> - Earlier finding fixed: the #3655 helper-body conflict (live_types, max_inst_id/max_blocks and write_inst cover live helper bodies, with a test that fails without it) - Earlier finding fixed: the measured-impact claims are gone; the smoke pairs are presented as regression checks only - The removed debug_asserts in bitstream.rs are replaced by runtime errors (width, abbrev id, Char6) surfaced through try_finish; production translation uses try_to_bitcode (graphics.rs ~1170), so a bad width fails the shader's translation and does not corrupt the stream or panic - FuncDecl::ptr is interned in declare(), so value_ty is total; unused function pointer types are still pruned (func_value_operand_survives_optimize_and_prunes_unused_func_ptrs) - Module::aggregate rejects Value::Inst elements whatever the module's instruction count (aggregate_constant_with_inst_operand_returns_error) - Every widened field (attr width from FnAttrs::MAX_INDEX, ty_w, val_w, bb_w, val_rel_w) is at least 1 bit, so emit never gets width 0 </details> <details><summary>How this was tested</summary> - Merged onto main `078358a0`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `078358a0` and on this merge; presents per 2 s at the end: 60 60 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
jsalzy commented 2026-12-03 01:00:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jsalzy on 2026-12-03T01:00:08Z.


merge-check claim
head: 66afe7a64a

<!-- greyfinch-sync:ivall/xcl:comment:7363835384 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#issuecomment-7363835384). Originally posted by [jsalzy](https://github.com/jsalzy) on 2026-12-03T01:00:08Z. --- merge-check claim head: 66afe7a64a994b7ab215166403bd60cf70dae9f3
jsalzy commented 2026-12-03 01:08:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jsalzy on 2026-12-03T01:08:48Z.


merge-check
base: 078358a058
head: 66afe7a64a
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3019 passed, 0 failed, 52 ignored (44 test binaries); SKIPPED: 25 (22 no wave64 on this GPU; 2 no heap windows (opt-in XCL_HEAP_WINDOWS=1); 1 driver cache cannot be disabled without Windows Developer Mode); failing: none. All 13 tests the PR adds ran and passed. git diff --check clean; 39 compiler warnings, the same as main.
title run: not run here (Foniass's check on this head has one).
review: (1) Size: one commit of +988/-200 (the description counts +604/-198 production and +384/-2 tests). It bundles separable parts: dead-type pruning with constant grouping, Char6 and fitted-width abbreviations, the interning caches (scalar_types, small_words, dx_ops) and the int_width/float_width queries. Foniass's earlier point still applies. (2) Interaction with other open PRs: #3654 (same author) conflicts with this one in module.rs (git merge-tree). #3707 merges with it without a text conflict, but it calls inline_helpers() before writing, so this PR's helper-body paths would go unused after both land (Foniass reports one helper-body test would then fail; not checked here). Whichever lands second has to adapt. (3) Scope: every direct-DXIL shader's bitcode changes, with no switch to turn it off. All GPU runs so far, this one included, are on NVIDIA, so AMD and Intel drivers haven't parsed these encodings yet (the PR has needs:amd-test). (4) Still open: Gevroska's RTX 3080 logs show compute pipeline creation in flight for ~51 s of the first 52 s on the merge, against <1 s on base. Nobody has compared a cold driver cache on both sides yet, and it wasn't measured here. Checked and fine: the Char6 table and the ArrayChar6 abbreviation definition match LLVM's encoding (Array = 3 with a Char6 = 4 element, counted as two operands). A fixed field or abbrev id that doesn't fit its width is now an error through try_finish, not a silent truncation. Production writes through try_to_bitcode (graphics.rs:1170) and Shader::try_finish (kernel.rs:913), so a bad width fails that shader's translation instead of producing a corrupt stream. Types are interned components-first (Module::ty takes existing Ty handles, and nothing changes a type after it's made), so the single reverse pass in live_types (module.rs:1558) marks every component of a live type. Helper-body instructions are included in live_types and the width fitting. Duplicates: I searched open and merged PRs for Char6, dead types bitcode, BLOCK_TYPE, bitcode compact, bitcode abbreviations, live_types, try_to_bitcode, interned constants, METADATA abbreviations, VALUE_SYMTAB and CST_CODE_SETTYPE, and checked #1607's groups (none lists 3645). None make the same change: #3250 (merged) added the function-block abbreviations this builds on, and #3654 / #3707 change the helper bodies, as in (2).
performance: On by default (reasoned, not measured here): smaller bitcode, and less translation work from the interning caches. The first start after this change misses the driver's shader cache for every direct-DXIL shader, as any translator change does. Whether the new encodings also take the driver longer to compile from a cold cache is still open (4).
verdict: safe to merge: no blocking finding, and the suite passes, all 13 new tests included. The points above are medium. Agrees with Foniass's check on this head.
hardware / tool and model: RTX 4070 SUPER 12 GB (621.24 / 32.0.16.2124), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 25H2 26200.9974, Rust 1.100.0, debug / Claude app (Claude Opus 5.5): merge, build and suite run on this PC with git and cargo only; diff review by Claude Opus 5.5.

<!-- greyfinch-sync:ivall/xcl:comment:7364004659 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#issuecomment-7364004659). Originally posted by [jsalzy](https://github.com/jsalzy) on 2026-12-03T01:08:48Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: 66afe7a64a994b7ab215166403bd60cf70dae9f3 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3019 passed, 0 failed, 52 ignored (44 test binaries); SKIPPED: 25 (22 no wave64 on this GPU; 2 no heap windows (opt-in XCL_HEAP_WINDOWS=1); 1 driver cache cannot be disabled without Windows Developer Mode); failing: none. All 13 tests the PR adds ran and passed. git diff --check clean; 39 compiler warnings, the same as main. title run: not run here (Foniass's check on this head has one). review: (1) Size: one commit of +988/-200 (the description counts +604/-198 production and +384/-2 tests). It bundles separable parts: dead-type pruning with constant grouping, Char6 and fitted-width abbreviations, the interning caches (scalar_types, small_words, dx_ops) and the int_width/float_width queries. Foniass's earlier point still applies. (2) Interaction with other open PRs: #3654 (same author) conflicts with this one in module.rs (git merge-tree). #3707 merges with it without a text conflict, but it calls inline_helpers() before writing, so this PR's helper-body paths would go unused after both land (Foniass reports one helper-body test would then fail; not checked here). Whichever lands second has to adapt. (3) Scope: every direct-DXIL shader's bitcode changes, with no switch to turn it off. All GPU runs so far, this one included, are on NVIDIA, so AMD and Intel drivers haven't parsed these encodings yet (the PR has needs:amd-test). (4) Still open: Gevroska's RTX 3080 logs show compute pipeline creation in flight for ~51 s of the first 52 s on the merge, against <1 s on base. Nobody has compared a cold driver cache on both sides yet, and it wasn't measured here. Checked and fine: the Char6 table and the ArrayChar6 abbreviation definition match LLVM's encoding (Array = 3 with a Char6 = 4 element, counted as two operands). A fixed field or abbrev id that doesn't fit its width is now an error through try_finish, not a silent truncation. Production writes through try_to_bitcode (graphics.rs:1170) and Shader::try_finish (kernel.rs:913), so a bad width fails that shader's translation instead of producing a corrupt stream. Types are interned components-first (Module::ty takes existing Ty handles, and nothing changes a type after it's made), so the single reverse pass in live_types (module.rs:1558) marks every component of a live type. Helper-body instructions are included in live_types and the width fitting. Duplicates: I searched open and merged PRs for Char6, dead types bitcode, BLOCK_TYPE, bitcode compact, bitcode abbreviations, live_types, try_to_bitcode, interned constants, METADATA abbreviations, VALUE_SYMTAB and CST_CODE_SETTYPE, and checked #1607's groups (none lists 3645). None make the same change: #3250 (merged) added the function-block abbreviations this builds on, and #3654 / #3707 change the helper bodies, as in (2). performance: On by default (reasoned, not measured here): smaller bitcode, and less translation work from the interning caches. The first start after this change misses the driver's shader cache for every direct-DXIL shader, as any translator change does. Whether the new encodings also take the driver longer to compile from a cold cache is still open (4). verdict: safe to merge: no blocking finding, and the suite passes, all 13 new tests included. The points above are medium. Agrees with Foniass's check on this head. hardware / tool and model: RTX 4070 SUPER 12 GB (621.24 / 32.0.16.2124), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 25H2 26200.9974, Rust 1.100.0, debug / Claude app (Claude Opus 5.5): merge, build and suite run on this PC with git and cargo only; diff review by Claude Opus 5.5.
Kalmarv commented 2026-12-03 13:10:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-03T13:10:34Z.


Rebased onto main (a815de932, after #3707) as cecb51868 with a 1-line test update for #3707:

  • Zero production-code diff vs 66afe7a64 (which received 2× verdict: safe to merge from @Foniass and @jsalzy).
  • Updated helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths in crates/xcl/src/gpu/dxil/module.rs to call m.write_bitcode(...) directly so #3707's Module::inline_helpers() in try_to_bitcode() does not inline helper.wide before exercising the HelperBody bitcode path.
  • Verified on RTX 5070 Ti (driver 610.74, rustc 1.99.0, DXC 1.9.2609.5): cargo build --release -p xcl clean (39 warnings, 0 new), cargo test --release -p xcl --lib -- dxil --skip gpu_ --skip fuzz_validate_and_gpu --skip bfm_and_ffbh_i_ir_and_gpu_parity --test-threads=4 (359 passed, 0 failed, 4 ignored; all 28 bitstream/bitreader_tests/module::tests passed, including #3707's inlined_rendezvous_is_one_loop_with_one_exit_and_first_lane_atomics), 60 s scripts/smoke.ps1 on cecb51868 (1373 frames on cold translated cache, 60 61 60, 0 device removals, 0 crashes, 15118 MB peak commit), and scripts/pr_check.py --local (description ok).

(Prepared with Antigravity, Gemini 4 Neon.)

<!-- greyfinch-sync:ivall/xcl:comment:7379425072 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#issuecomment-7379425072). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-03T13:10:34Z. --- Rebased onto `main` (`a815de932`, after #3707) as `cecb51868` with a 1-line test update for #3707: - **Zero production-code diff vs `66afe7a64`** (which received 2× `verdict: safe to merge` from `@Foniass` and `@jsalzy`). - Updated `helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths` in `crates/xcl/src/gpu/dxil/module.rs` to call `m.write_bitcode(...)` directly so #3707's `Module::inline_helpers()` in `try_to_bitcode()` does not inline `helper.wide` before exercising the `HelperBody` bitcode path. - Verified on RTX 5070 Ti (driver 610.74, `rustc 1.99.0`, DXC `1.9.2609.5`): `cargo build --release -p xcl` clean (39 warnings, 0 new), `cargo test --release -p xcl --lib -- dxil --skip gpu_ --skip fuzz_validate_and_gpu --skip bfm_and_ffbh_i_ir_and_gpu_parity --test-threads=4` (359 passed, 0 failed, 4 ignored; all 28 `bitstream`/`bitreader_tests`/`module::tests` passed, including #3707's `inlined_rendezvous_is_one_loop_with_one_exit_and_first_lane_atomics`), 60 s `scripts/smoke.ps1` on `cecb51868` (1373 frames on cold translated cache, `60 61 60`, 0 device removals, 0 crashes, 15118 MB peak commit), and `scripts/pr_check.py --local` (`description ok`). *(Prepared with Antigravity, Gemini 4 Neon.)*
Foniass commented 2026-12-03 17:06:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T17:06:58Z.


merge-check
base: 16c2fd082a
head: cecb518680
merge: clean
build: ok
tests: 3031 passed, 0 failed, 56 ignored; 28 skipped, the same as on main
review: 5 medium (below)
performance: 60 s smoke run: 1683 → 1643 frames (97 % of main), peak commit 18505 → 17277 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 216 s there, 0 device removals, 0 crashes, 3.3 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
verdict: safe to merge: no blocking finding (the points below are medium or nits), the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: Compacts direct-DXIL bitcode by default: removes unused types, groups constants by type, packs bitcode tables tighter (Char6 strings, fitted field widths) and caches common types, constants and declarations. Since my last merge-check on 66afe7a6 the production code is unchanged: the commit was rebased onto main a815de93 (after #3707), and one test now calls write_bitcode directly so #3707's helper inlining runs after it. Nothing blocks merging; the open points are medium.

Medium

  1. Size and scope still over the limit. One commit of +991/-200 (1191 changed lines) holding several separable changes. The "why one PR" paragraph only ties dead-type pruning to ty_w. The interning caches (scalar_types, small_words, dx_ops), the int_width/float_width queries and the Char6 abbreviations don't depend on pruning and could each be their own PR. Earlier finding still open.
  2. Helper-body bitcode code is now unreachable in production. After #3707, try_to_bitcode (module.rs ~1235) calls inline_helpers() before write_bitcode and clears every helper_body, so this PR's helper-body handling only runs from the one test that calls write_bitcode directly: helper_local_types (~1956), the helper type marking in live_types (~1752), the helper width fitting (~1600) and the internal-linkage function abbreviation. That is dead weight in a PR already over the size limit. Drop it (with helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths), or say in the description why it stays.
  3. On by default for every direct-DXIL shader, NVIDIA only. Every direct-DXIL shader's bitcode changes, with no switch to turn it off. GPU runs exist only on NVIDIA (RTX 5070 Ti, RTX 4070 SUPER, Gevroska's RTX 3080); AMD and Intel drivers have never parsed these encodings (needs:amd-test). Earlier finding still open.
  4. Cold-start pipeline creation cost still not measured. Gevroska's RTX 3080 logs show a compute pipeline creation call in flight for ~51 s of the first 52 s on the merge, against under 1 s on base. The author's new cecb5186 smoke run is also a cold driver cache, against a warm main: 1373 against 1700 frames (81 %, just over the 80 % bar). Nobody has compared a cold cache on both sides yet, so whether the new encodings are slower for the driver to compile is still open. Earlier finding still open. A first number from this merge-check's title run (cache rebuilt because the translator changed): shader preparation took 199 s and the world was reached 83.2 s after the title started, against 7 s and 68.7 s on main. Another translator change (#3748, last night's run) took 60 s and 76.5 s, so this PR's preparation looks about three times slower than a typical translator change; one run, not a cold-versus-cold comparison.
  5. No issue link in the description. The description has no "Fixes #N" or "Part of #N". Link the roadmap or tracking issue this size work belongs to.
Checked and fine
  • Earlier finding fixed: the #3707 conflict. The rebase onto a815de93 is clean, and the helper-body test now calls write_bitcode directly, so it no longer fails after #3707's inline_helpers
  • Earlier finding no longer applies: #3654 is closed, so its module.rs conflict and its unmarked CallOutput type are gone
  • Since 66afe7a6 (the head of my last merge-check), the commits differ only in that test and the place where it sits in the tests module; the production diff is byte-identical
  • try_to_bitcode is the only production caller of write_bitcode, so every shader goes through inline_helpers and the entry-only type pruning and width fitting cover the inlined helper instructions
  • spin_wait_and_barrier_arrive_helpers_validate_with_compacted_bitcode now goes through try_finish, so it checks the inlined helpers against DXC with the compacted encoding
  • The base is current origin/main a815de93; git diff --check is clean
How this was tested
  • Merged onto main 16c2fd08, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 16c2fd08 and on this merge; presents per 2 s at the end: 60 60 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7385985749 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3645#issuecomment-7385985749). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T17:06:58Z. --- merge-check base: 16c2fd082ae2e96967a2ab553bc2e1032e491f70 head: cecb518680e7d199b14cc9c30eb67f1c330d788f merge: clean build: ok tests: 3031 passed, 0 failed, 56 ignored; 28 skipped, the same as on main review: 5 medium (below) performance: 60 s smoke run: 1683 → 1643 frames (97 % of main), peak commit 18505 → 17277 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 216 s there, 0 device removals, 0 crashes, 3.3 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) verdict: safe to merge: no blocking finding (the points below are medium or nits), the suite passes and the smoke run is clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** Compacts direct-DXIL bitcode by default: removes unused types, groups constants by type, packs bitcode tables tighter (Char6 strings, fitted field widths) and caches common types, constants and declarations. Since my last merge-check on 66afe7a6 the production code is unchanged: the commit was rebased onto main a815de93 (after #3707), and one test now calls write_bitcode directly so #3707's helper inlining runs after it. Nothing blocks merging; the open points are medium. #### Medium 1. **Size and scope still over the limit.** One commit of +991/-200 (1191 changed lines) holding several separable changes. The "why one PR" paragraph only ties dead-type pruning to ty_w. The interning caches (scalar_types, small_words, dx_ops), the int_width/float_width queries and the Char6 abbreviations don't depend on pruning and could each be their own PR. Earlier finding still open. 2. **Helper-body bitcode code is now unreachable in production.** After #3707, try_to_bitcode (module.rs ~1235) calls inline_helpers() before write_bitcode and clears every helper_body, so this PR's helper-body handling only runs from the one test that calls write_bitcode directly: helper_local_types (~1956), the helper type marking in live_types (~1752), the helper width fitting (~1600) and the internal-linkage function abbreviation. That is dead weight in a PR already over the size limit. Drop it (with helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths), or say in the description why it stays. 3. **On by default for every direct-DXIL shader, NVIDIA only.** Every direct-DXIL shader's bitcode changes, with no switch to turn it off. GPU runs exist only on NVIDIA (RTX 5070 Ti, RTX 4070 SUPER, Gevroska's RTX 3080); AMD and Intel drivers have never parsed these encodings (needs:amd-test). Earlier finding still open. 4. **Cold-start pipeline creation cost still not measured.** Gevroska's RTX 3080 logs show a compute pipeline creation call in flight for ~51 s of the first 52 s on the merge, against under 1 s on base. The author's new cecb5186 smoke run is also a cold driver cache, against a warm main: 1373 against 1700 frames (81 %, just over the 80 % bar). Nobody has compared a cold cache on both sides yet, so whether the new encodings are slower for the driver to compile is still open. Earlier finding still open. A first number from this merge-check's title run (cache rebuilt because the translator changed): shader preparation took 199 s and the world was reached 83.2 s after the title started, against 7 s and 68.7 s on main. Another translator change (#3748, last night's run) took 60 s and 76.5 s, so this PR's preparation looks about three times slower than a typical translator change; one run, not a cold-versus-cold comparison. 5. **No issue link in the description.** The description has no "Fixes #N" or "Part of #N". Link the roadmap or tracking issue this size work belongs to. <details><summary>Checked and fine</summary> - Earlier finding fixed: the #3707 conflict. The rebase onto a815de93 is clean, and the helper-body test now calls write_bitcode directly, so it no longer fails after #3707's inline_helpers - Earlier finding no longer applies: #3654 is closed, so its module.rs conflict and its unmarked CallOutput type are gone - Since 66afe7a6 (the head of my last merge-check), the commits differ only in that test and the place where it sits in the tests module; the production diff is byte-identical - try_to_bitcode is the only production caller of write_bitcode, so every shader goes through inline_helpers and the entry-only type pruning and width fitting cover the inlined helper instructions - spin_wait_and_barrier_arrive_helpers_validate_with_compacted_bitcode now goes through try_finish, so it checks the inlined helpers against DXC with the compacted encoding - The base is current origin/main a815de93; git diff --check is clean </details> <details><summary>How this was tested</summary> - Merged onto main `16c2fd08`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `16c2fd08` and on this merge; presents per 2 s at the end: 60 60 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
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/3645:upstream-pr/3645'
git switch 'upstream-pr/3645'

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/3645'
git switch 'upstream-pr/3645'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3645'
git switch 'upstream-pr/3645'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3645'
git switch 'main'
git merge --squash 'upstream-pr/3645'
git switch 'main'
git merge --ff-only 'upstream-pr/3645'
git switch 'main'
git merge 'upstream-pr/3645'
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
xcl-dev/xcl!3645
No description provided.