Recompiler: compact DXIL bitcode tables, types, and interned constants #3645
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3645"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from 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/-200across 9 files incrates/xcl/src/gpu/dxil/:+604/-198production code and+387/-2unit/bitreader/DXC-validation tests).module.rs):#3655internalHelperBodyfunctions (live_types,helper_local_types) before emittingBLOCK_TYPE.FuncDecl::ptr) indeclare()(matchingGlobalDef::ptr) sovalue_tyis total and O(1) acrossoptimize(), read-only scans, and emission whilelive_typesprunes unused function pointer types fromBLOCK_TYPE.(nesting depth, remapped type)soCST_CODE_SETTYPEis emitted once per live type while keeping aggregate elements ahead of parents, and reject non-constantValue::Instelements deterministically inModule::aggregate().bitstream.rs,module.rs,bitreader_tests.rs):ArrayChar6encoding and abbreviateMODULE_CODE_FUNCTION(preserving prototype flag, internal/external linkage for helper bodies, andFnAttrs::MAX_INDEXattribute width),BLOCK_TYPEstruct/pointer/function records,BLOCK_METADATAstrings/names/nodes, andVALUE_SYMTABentries.ty_w,sym_w,md_idx_w,val_w,val_rel_w, andbb_wacross both the entry body and all live helper bodies, and tighten function-block VBR widths.ArrayChar6operands at runtime inBitWriterand surface errors throughBitWriter::try_finish/Module::try_to_bitcodeinstead of silently truncating in release builds.module.rs,module/split.rs,shader.rs,ops.rs,lower.rs,lower_valu.rs):scalar_types), smalli32constants (small_words, preserved byModule::declarations()), and matchingdx.op.*declarations (dx_ops).int_width/float_widthwithout interning unused 64-bit types during lowering.bitstream.rs,module.rs,bitreader_tests.rs,core_tests.rs):compute_omits_rodata_without_s_getpcto store the loaded value so thes_getpc_b64case checks a livexcl_rodataprobe instead of an unpruned dead array type.#3655helper-only types and wider helperval_rel_w/bb_wwidths (helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths), DXC validation ofspin_wait/barrier_arrivehelpers (spin_wait_and_barrier_arrive_helpers_validate_with_compacted_bitcode),Value::Funcoperands acrossoptimize()+ unused function-pointer pruning (func_value_operand_survives_optimize_and_prunes_unused_func_ptrs), deterministicValue::Instrejection inModule::aggregate()(aggregate_constant_with_inst_operand_returns_error), andBitWriterfixed-field overflow errors (fixed_field_overflow_returns_error_instead_of_corrupting_stream).+604/-198(the remaining+387/-2lines are tests). Dead-type pruning, non-interning width queries, and the fitted table abbreviations work as one encoding pass inmodule.rsbecause pruning determines the exact livety_wused acrossBLOCK_TYPE,BLOCK_CONSTANTS,BLOCK_METADATA,MODULE_CODE_FUNCTION, andFuncAbbrevs.Tested
rustc 1.99.0 (b940084d7 2026-09-28), DXC1.9.2609.5(debug + release).cecb51868(rebased ontomaina815de932after#3707, with zero production-code diff vs66afe7a64— onlyhelper_bodies_retain_helper_only_types_and_widen_func_abbrev_widthsupdated to callm.write_bitcode(...)directly before#3707'sinline_helpers()):cargo build --release -p xcl: clean (39 warnings; 0 new vsmain).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(DXC1.9.2609.5): 359 passed, 0 failed, 4 ignored (12SKIPPEDno wave64subcases inlower_dxil::tests; all 28 tests acrossgpu::dxil::bitstream::tests,gpu::dxil::bitreader_tests, andgpu::dxil::module::testspassed, includinghelper_bodies_retain_helper_only_types_and_widen_func_abbrev_widthsand#3707'sinlined_rendezvous_is_one_loop_with_one_exit_and_first_lane_atomics).66afe7a64(identical production code before the#3707rebase):scripts/test.ps1(cargo build --workspace,cargo bench -p xcl --bench '*' -- --test,cargo test --workspace -- --test-threads=4, DXC1.9.2609.5): 2987 passed, 0 failed, 52 ignored across all 43 test targets (24SKIPPEDGPU tests on this adapter: 22no wave64, 2no heap windows; 0 DXC skips).Regression run
Regression check only (same title;
cecb51868is a single cold-translated-cache 60 s run after the 1-line test edit inmodule.rschangedXCL_DIRECT_DXIL_SOURCE_ID, settling at60 61 60presents per 2 s; prior warm 60 s runs on identical production code66afe7a64recorded 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):PR head:
Not tested
1.9.2609.5and NVIDIA, but AMD's DXIL reader has not yet executed them.XCL_HEAP_WINDOWS=1GPU tests (2 skipped under defaultscripts/test.ps1).scripts/test.ps1/gpu_*tests were not re-run locally oncecb51868(production code is unchanged vs66afe7a64, where the full suite passed 2987/0/52).cecb51868.AI use
GPT-6) wrote the initial bitcode compaction and interning changes during an offline DXIL size sweep.Gemini 4 Neon) cherry-picked and rebased them ontomain(a815de932), fixed the#3655HelperBodyintegration,@bmjask'sValue::Func/Module::aggregate/BitWriterfindings, and the#3707helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widthstest update, rancargo build --release -p xcl, DXIL unit tests (cecb51868), fullscripts/test.ps1(66afe7a64), and the 60 s smoke runs, and drafted this description.Imported from ivall/xcl. Originally posted by SavageCore on 2026-12-02T04:31:10Z.
Review: APPROVED
sorry, ignore, agent went crazy
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T08:59:17Z.
Review (head
bc479215, diff read, not a merge-check):scalar_types,small_words,dx_ops), and the scalar-width queries inops.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.live_types(module.rs~1336) marks types only from entry-body instructions inorder, andval_rel_w/bb_wcome from the entry body only. #3655 writes internal helper bodies frombody.instructionswith rawinst.ty.0type IDs (#3655module.rs~1289). After both merge, a type that only a helper uses either hitsexpect("use of a dropped type")or is written with an unremapped ID. #3654 (stacked on this PR) already extendsmark_instandmax_inst_idto cover its helper bodies. Whichever of #3645/#3655 lands second has to make the same change for #3655's bodies.bitreader_testsreader, 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, andval_rel_wfor 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 throughcmap/tmap.declarations()copiessmall_wordstogether withconsts, and thedx_opscache rechecks name, suffix, return and parameter types.compute_omits_rodata_without_s_getpcstill 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.
Imported from ivall/xcl. Originally posted by Gevroska on 2026-12-02T11:11:03Z.
merge-check
base:
1c8b551475head:
bc47921593merge: 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.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T11:50:37Z.
merge-check
base:
1c8b551475head:
bc47921593merge: 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
1c8b5514vs 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.
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 head0cd5086ff:#3655HelperBodysemantic conflict (@Foniass):live_typesandwrite_instnow walk live helper bodies using helper-local SSA types (helper_local_types),max_inst_id/max_blocksinclude live helper bodies soval_rel_wandbb_wcover helper blocks and call relative IDs, andMODULE_CODE_FUNCTIONemitsprotoandLINKAGE_INTERNALthrough the abbreviated function record. Addedhelper_bodies_retain_helper_only_types_and_widen_func_abbrev_widths(fails if helper-onlyi16is pruned or ifbb_w/val_rel_wcome from the entry body alone) andspin_wait_and_barrier_arrive_helpers_validate_with_compacted_bitcode(validates#3655'sxcl.spin.waitandxcl.barrier.arrivewith DXC1.9.2609.5).+563/-172production code ++293tests, with dead-type pruning determining the livety_wused 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.gpu/dxil/*.rsand emitted bitcode bytes compiles startup pipelines cold (1303 frames here, 0 removals, 0 crashes), while the warm run matchesmain(1694vs1685frames shown,61 60 60presents per 2 s,15199vs16337 MBpeak commit, 0 removals, 0 crashes).Verification on
0cd5086ff(RTX 5070 Ti, driver 610.74, Ryzen 9 9950X, Windows 11 26200,rustc 1.99.0, DXC1.9.2609.5):cargo build --release -p xcl: ok (39 warnings; 0 new vsmain).scripts/test.ps1(with DXC1.9.2609.5): 2984 passed, 0 failed, 52 ignored across 43 test targets (24SKIPPEDGPU tests: 22no wave64, 2no heap windows; 0 DXC skips).python scripts/pr_check.py --local:description ok.AI use: Antigravity (
Gemini 4 Neon) rebased#3645, implemented the#3655HelperBodyfix and tests, ran the verification suite and smoke pair, and drafted this reply.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.crates/xcl/src/gpu/dxil/module.rs:1935: see below.crates/xcl/src/gpu/dxil/bitstream.rs:60: see below.On lines outside the diff:
Medium
crates/xcl/src/gpu/dxil/module.rs:1935: Not certain about this one: the PR removed thewrite_bitcodeloop that internedPtr(func_ty, 0)for every function, butvalue_tystill indexestype_ids[&TypeDef::Ptr(..)]forValue::Func, and its comment still says the pointer types already exist. So the writer'sval_tycalls (Gep base, Alloca size, Switch operand,live_types) can hit a missing key and panic intry_to_bitcode, which is meant to return builder errors as Err. A function value fromfunc_value()that never went throughtype_of/md_valuereaching such a path would panic while writing.declare_dx_opalready special-casesValue::Func(~568) for this. Interning the pointer type lazily invalue_tywould make it safe.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, butemitonly checks that a value fits its width withdebug_assert!, so an oversized value silently corrupts the bitstream in release builds. IfFnAttrs::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) overflowsArrayFixed(val_w)at module.rs:1316. In both casesvalue << nbitsORs 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.
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.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T18:08:10Z.
merge-check
base:
5eaadb54c1head:
0cd5086ff8merge: 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(sincebc479215, 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. Thebuild.rssource hash invalidates caches automatically. Findings: (1) Semantic conflict with #3655: fixed.live_typesmarks helper-local types (helper_local_types, module.rs ~1601–1620).max_inst_id/max_blocksinclude helper bodies (~1216–1223), andwrite_instgets 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 toFixed(ty_w). The interning caches (scalar_types,small_words,dx_ops), theint_width/float_widthqueries 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-treeis clean, but #3707 callsinline_helpers()beforewrite_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 ofmodule.rs(FuncAbbrevs::defineagainst #3654's shared BLOCKINFO abbreviations, the helper-block abbreviation, the tests). It is semantic too: #3654'sOp::CallOutputwrites a rawinst.ty.0, whichmark_insthere 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). Thedx_opscache 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
5eaadb54vs 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.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T18:16:59Z.
Thanks
@bmjaskfor the two findings and@Foniassfor the follow-upmerge-check! Both of@bmjask's findings were valid edge cases and are now fixed in253c0271a:Value::Funcpointer-type interning (module.rs): Addedensure_func_ptr_typesright beforelive_typesinwrite_bitcodesoPtr(f.ty, 0)is lazily interned for any function actually referenced as a liveValue::Funcoperand (while ordinaryOp::Callcallees 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) totry_value_tyso an un-internedValue::Funccan never panic. Covered byfunc_value_operand_interns_pointer_type_without_panicking.bitstream.rs,module.rs): Replaceddebug_assert!width/abbrev-id checks inBitWriter::emitanddefine_abbrev(plusArrayChar6lookup) with runtime error recording surfaced viaBitWriter::try_finish->Module::try_to_bitcode, and derivedMODULE_CODE_FUNCTION's attribute width fromFnAttrs::MAX_INDEX. Covered byfixed_field_overflow_returns_error_instead_of_corrupting_streamandaggregate_constant_with_inst_operand_returns_bitstream_error.Regarding
@Foniass's notes for@Prime1997:+679/-190production,+379/-2tests) for review; happy to split out the interning caches / width queries / Char6 abbreviations if@Prime1997prefers.#3654(Op::CallOutputtype remapping) and#3707(inline_helpers) interactions —#3654is currently rebased independently onmain, and whichever lands second will adapt.Verification on
253c0271a(RTX 5070 Ti, driver 610.74, DXC1.9.2609.5):cargo build --release -p xcl: clean, 39 warnings (0 new vsmain5eaadb54c).scripts/test.ps1: 2987 passed, 0 failed, 52 ignored across 43 targets (24SKIPPEDGPU tests: 22no wave64, 2no heap windows; 0 DXC skips;cargo bench -p xcl --bench '*' -- --testpassed).scripts/smoke.ps1pair (title: ea3b5e4d):main5eaadb54c1684 frames (0 removals, 0 crashes, 17495 MB) vs253c0271a1680 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.)
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 fromdebug_assert!-only width checks looks addressed: the writer now has an error path. TheValue::Funcpointer-type panic is fixed for the bitcode writer (ensure_func_ptr_types), but the same panic is still reachable earlier, fromoptimize()(below).crates/xcl/src/gpu/dxil/module/opt.rs:518: see below.On lines outside the diff:
crates/xcl/src/gpu/dxil/module/opt.rs:518: The PR says read-only scans are guarded withtry_value_ty, butoptimize()still calls the panickingvalue_tyon every operand: inremovable()here, and at opt.rs 136/188/192/417/446/487/494/928/1054/1063/1082.ensure_func_ptr_typesruns only later, insidewrite_bitcode. So a module that does what the new testfunc_value_operand_interns_pointer_type_without_panickingdoes (m.switch(m.func_value(callee), ..), or a call takingfunc_value(f)as an argument) and then goes through the normalShader::try_finish/kernelpath panics in the DCE loop (opt.rs:1454) with "function pointer type not interned". The test passes only because it skipsoptimize(). InterningPtr(f.ty, 0)infunc_value, or putting back the eager interning loop (live_typesnow 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.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T18:48:34Z.
Good catch
@bmjask— updated toc40ec9800(and simplified the diff by ~70 lines):ptr: TyonFuncDeclinsidedeclare()(matchingGlobalDef::ptr), sovalue_ty(&self, v: Value)is total and O(1) acrossoptimize()(opt.rs),declare_dx_op, read-only scans, andwrite_bitcode, and removedensure_func_ptr_types/try_value_ty.live_typesstill prunes unused function pointer types before emittingBLOCK_TYPE.func_value_operand_survives_optimize_and_prunes_unused_func_ptrs, which runsm.optimize()followed bym.try_to_bitcode(...)and asserts only the referencedValue::Func's pointer type is emitted inBLOCK_TYPE.Verification on
c40ec9800(RTX 5070 Ti, driver 610.74, DXC1.9.2609.5):cargo build --release -p xcl: clean, 39 warnings (0 new vsmain5eaadb54c).scripts/test.ps1: 2987 passed, 0 failed, 52 ignored across 43 targets (24SKIPPEDGPU tests: 22no wave64, 2no heap windows; 0 DXC skips;cargo bench -p xcl --bench '*' -- --testpassed).scripts/smoke.ps1pair (title: ea3b5e4d):main5eaadb54c1709 frames (0 removals, 0 crashes, 16892 MB) vsc40ec9800warm 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.)
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. TheValue::Funcpanic fromoptimize()reported on253c0271wasn't flagged again and looks addressed. The bad-aggregate-element case from the0cd5086freview is only partly covered (below).crates/xcl/src/gpu/dxil/module.rs:1299: An aggregate constant with aValue::Instelement is reported only when the instruction's id happens to overflowval_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.
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 1299Medium: An aggregate constant with a
Value::Instelement is reported only when the instruction's id happens to overflowval_w. Nothing checks that aggregate elements are constants, so the 'error instead of corruption' path, andaggregate_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, andtry_to_bitcodereturns 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 inaggregate()(or inlive_values) and callingfailwould make it deterministic.Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T19:19:38Z.
Good catch
@bmjask— updated to66afe7a64:Module::aggregate()now checkselemsdirectly and records a builder error (self.fail(...)) on anyValue::Instelement, regardless of instruction count orval_w(whileBitWriter::emitstill catches any fixed-field overflow independently).aggregate_constant_with_inst_operand_returns_error, using a single instruction whose absolute ID still fitsFixed(val_w).Verification on
66afe7a64(RTX 5070 Ti, driver 610.74, DXC1.9.2609.5):cargo build --release -p xcl: clean, 39 warnings (0 new vsmain5eaadb54c).scripts/test.ps1: 2987 passed, 0 failed, 52 ignored across 43 targets (24SKIPPEDGPU tests: 22no wave64, 2no heap windows; 0 DXC skips;cargo bench -p xcl --bench '*' -- --testpassed).scripts/smoke.ps1pair (title: ea3b5e4d):main5eaadb54c1700 frames (0 removals, 0 crashes, 16914 MB) vs66afe7a641702 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.)
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(base1c8b5514, tested mergeebcf2eba). I aligned each run at the end of the first sampling interval that recorded a presentation, then compared the next 52 seconds.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.rstests on Windows. All 4 passed on078358a0, and all 6 passed on66afe7a6, including the Char6 and fixed-field error cases. That check was CPU-only. I don’t have a driver-timing comparison for66afe7a6yet.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.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T23:37:07Z.
Thanks
@Gevroskafor digging into the RTX 3080 logs and verifying thebitstream.rstests on66afe7a64.That
0.43–0.77 svs50.8 scompute pipeline-creation in-flight gap matches what we saw on RTX 5070 Ti: because#3645changes the emitted bitcode bytes of every direct-DXIL shader, the first run with#3645misses the shared NVIDIA driver cache (even in merge-first order ifmainalready 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 matchedmain(1702/1707frames on66afe7a64vs1700onmain,60 60 60presents 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.)
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T00:52:54Z.
merge-check
base:
078358a058head:
66afe7a64amerge: 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
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.Checked and fine
How this was tested
078358a0, thencargo build --workspaceandcargo test --workspace --no-fail-fast -- --test-threads=4.scripts/smoke.ps1: 60 s of a retail title on main078358a0and on this merge; presents per 2 s at the end: 60 60 60.XCL_RUN_SECONDS=300and 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.
Imported from ivall/xcl. Originally posted by jsalzy on 2026-12-03T01:00:08Z.
merge-check claim
head:
66afe7a64aImported from ivall/xcl. Originally posted by jsalzy on 2026-12-03T01:08:48Z.
merge-check
base:
078358a058head:
66afe7a64amerge: 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.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-03T13:10:34Z.
Rebased onto
main(a815de932, after #3707) ascecb51868with a 1-line test update for #3707:66afe7a64(which received 2×verdict: safe to mergefrom@Foniassand@jsalzy).helper_bodies_retain_helper_only_types_and_widen_func_abbrev_widthsincrates/xcl/src/gpu/dxil/module.rsto callm.write_bitcode(...)directly so #3707'sModule::inline_helpers()intry_to_bitcode()does not inlinehelper.widebefore exercising theHelperBodybitcode path.rustc 1.99.0, DXC1.9.2609.5):cargo build --release -p xclclean (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 28bitstream/bitreader_tests/module::testspassed, including #3707'sinlined_rendezvous_is_one_loop_with_one_exit_and_first_lane_atomics), 60 sscripts/smoke.ps1oncecb51868(1373 frames on cold translated cache,60 61 60, 0 device removals, 0 crashes, 15118 MB peak commit), andscripts/pr_check.py --local(description ok).(Prepared with Antigravity, Gemini 4 Neon.)
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T17:06:58Z.
merge-check
base:
16c2fd082ahead:
cecb518680merge: 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
66afe7a6the production code is unchanged: the commit was rebased onto maina815de93(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
cecb5186smoke 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.Checked and fine
a815de93is clean, and the helper-body test now calls write_bitcode directly, so it no longer fails after #3707's inline_helpers66afe7a6(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-identicala815de93; git diff --check is cleanHow this was tested
16c2fd08, thencargo build --workspaceandcargo test --workspace --no-fail-fast -- --test-threads=4.scripts/smoke.ps1: 60 s of a retail title on main16c2fd08and on this merge; presents per 2 s at the end: 60 60 60.XCL_RUN_SECONDS=300and 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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.