Recompiler: prune unused module constants and dead-aggregate globals in direct DXIL bitcode #2640
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2640
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2640"
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?
@Decodere on GitHub · 2026-11-26 04:24 UTC · original
Decodere:fix-dxil-prune-unused-constants→main· +159 −35 · 1 files · 1 commits · openWhat is in it
Prunes unused module constants and fixes dead-aggregate global/function retention during direct DXIL bitcode serialization in
crates/xcl/src/gpu/dxil/module.rs:Module::live_values): Computes(gused, fused, cused)over reachable blocks (order) and metadata (MdDef::Val), seedingOp::Callcallees + args, only reachable incoming edges ofOp::Phi(matchingwrite_inst), and all otherOp::for_each_operandoperands. TracesGlobalDef::initandConstDef::Aggregateelements only once the owning global or constant is marked live.write_bitcodescanned everyConstDef::Aggregateinself.consts, so an unreferenced aggregate referencing an otherwise-unused internal global or function kept that declaration alive in the emitted module.BLOCK_CONSTANTSwithout mutatingModule: Buildscmap: Vec<Option<u64>>in original constant order (preservingelem_idx < agg_idxordering forCST_CODE_AGGREGATE), mapsValue::Const(c)throughconst_base + cmap[c], omitsBLOCK_CONSTANTSwhenn_consts == 0, and emits onlycusedentries while keepingwrite_bitcodeidempotent.Part of #2508
Part of #1833
Tested
live_valuessemantics (cargo test --release -p xcl --lib "gpu::dxil::module::tests::" -- --test-threads=1 --nocapture):3 passed; 2 failed; 0 ignored:unused_scalar_constants_produce_identical_bitcodefailed (dead constant 3 retained)dead_aggregate_does_not_retain_unused_global_while_live_global_init_is_keptfailed (unexpected global liveness: [true, true, false], confirmingdead_aggretainedg_dead_inner)XCL_ADAPTER=warp,XCL_WARP=1,cargo test --release -p xcl --lib "gpu::dxil::module::tests::" -- --test-threads=1 --nocapture):5 passed; 0 failed; 0 ignored; 0 skipped(0.01s, DXC1.9.2609.5validated and disassembled the pruned shader container; zero warnings inmodule.rs).cargo test --release -p xcl --lib "gpu::dxil::" -- --test-threads=1 --nocapture):187 passed; 0 failed; 3 ignored(36.91s,gpu::dxil::module::tests::5/0/0,0skipped;1pre-existingSKIPPED:gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole: no wave64).Regression run
Full release workspace on RTX 4060 (
cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture):37test binaries,1438 passed; 0 failed; 47 ignored,29pre-existing environment-gatedSKIPPEDlines:21skipped:no wave64(RTX 4060 is wave32)3skipped: wave32per-lane form: refusedby driver (f16 arithmetic,f16 packed,f32 conversions)3skipped: no D3D12 debug layer (d3d12SDKLayers.dllunavailable on host: debug-layerdred: false/trueanduploads_start_from_each_subresources_state)1skipped:pso_measurement_compiles_an_exact_synthetic_record(cannot disable driver cache on Windows)1skipped:heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows)Paired 60 s RTX 4060 smoke capture (
scripts/smoke.ps1):Base (
origin/mainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7):PR (
b7cfe9b224f31ddf6ba06c2d614bc446132b6062):Not tested
29host-gated workspace tests skipped on this RTX 4060 machine (wave64 hardware, wave32 per-lane driver support, D3D12 SDK debug layer, driver cache disable, and heap windows).AI use
Google Antigravity (Gemini 4 Neon) wrote the patch, unit tests, and PR description; all commands, test runs, and paired 60 s GPU smoke captures were executed directly in this workspace.
@DarkPanda69 on GitHub · 2026-11-26 04:37 UTC · original
Native wave64 run (the wave64 tests skipped on the RTX 4060) on an AMD RX 9070 XT, plus an RTX 3060: the 3 new tests pass, and nothing else changes in the direct-DXIL GPU suite.
Head
b7cfe9bapplied onmainb49be18, debug, Windows 11 Pro 26200,XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4onmainand with the PR, card chosen withXCL_ADAPTER:mainOn both cards, the only result changes against
mainare the newdead_aggregate_does_not_retain_unused_global_while_live_global_init_is_kept,pruned_direct_dxil_shader_with_live_table_and_dead_constants_validatesandunused_scalar_constants_produce_identical_bitcode, all ok, with no new skips. So every direct-DXIL program in the suite, including the wave64 ones that skip on a 32-lane card, went through the pruned bitcode on the RX 9070 XT and still validates and runs. The 2 RX 9070 XT failures are the AMD fuzz seeds tracked in #2115, the same onmain.Not tested: cold-cache rebuild timings, the D3D12 debug-layer tests (no
d3d12SDKLayers.dllhere either), a title.AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
github-bot referenced this pull request2026-11-26 12:40:17 +00:00
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.