Skip to content

Add DebugBuildIdentifier to the live worklist during initialization#6626

Merged
s-perron merged 4 commits intoKhronosGroup:mainfrom
jkwak-work:fix/dbi-for-aggressive-dce
Apr 20, 2026
Merged

Add DebugBuildIdentifier to the live worklist during initialization#6626
s-perron merged 4 commits intoKhronosGroup:mainfrom
jkwak-work:fix/dbi-for-aggressive-dce

Conversation

@jkwak-work
Copy link
Copy Markdown
Contributor

DebugBuildIdentifier was missing from the set of NonSemantic debug instructions added to the worklist in InitializeModuleScopeLiveInstructions. Instead it was handled in ProcessGlobalValues (after the worklist is exhausted) using live_insts_.Set() on its direct operands.

live_insts_.Set() marks an instruction live but does not enqueue it, so transitive operand dependencies are never visited. In shaders where the only use of a type (e.g. OpTypeInt) is through a constant that is itself only referenced by DebugBuildIdentifier's flags argument, the type instruction is not marked live and is incorrectly killed by ADCE.

The surviving constant then references a deleted type, producing invalid SPIR-V. Any subsequent pass that rebuilds the DefUseManager (e.g. CCP) will fail with "Definition is not registered."

Fix: include NonSemanticShaderDebugInfo100DebugBuildIdentifier in the worklist loop alongside the other always-live debug instructions. The worklist's transitive closure correctly marks all operand dependencies live before global-value cleanup runs. The existing special-case code in ProcessGlobalValues becomes unreachable for this opcode (IsLive returns true, so the early continue fires) and is now dead; it is left in placefor safety.

jkwak-work and others added 2 commits April 3, 2026 04:56
DebugBuildIdentifier was missing from the set of NonSemantic debug                                                                             instructions added to the worklist in InitializeModuleScopeLiveInstructions.
Instead it was handled in ProcessGlobalValues (after the worklist is
exhausted) using live_insts_.Set() on its direct operands.

live_insts_.Set() marks an instruction live but does not enqueue it, so
transitive operand dependencies are never visited. In shaders where the
only use of a type (e.g. OpTypeInt) is through a constant that is itself
only referenced by DebugBuildIdentifier's flags argument, the type
instruction is not marked live and is incorrectly killed by ADCE.

The surviving constant then references a deleted type, producing invalid
SPIR-V. Any subsequent pass that rebuilds the DefUseManager (e.g. CCP)
will fail with "Definition is not registered."

Fix: include NonSemanticShaderDebugInfo100DebugBuildIdentifier in the
worklist loop alongside the other always-live debug instructions. The
worklist's transitive closure correctly marks all operand dependencies
live before global-value cleanup runs. The existing special-case code in
ProcessGlobalValues becomes unreachable for this opcode (IsLive returns
true, so the early continue fires) and is now dead; it is left in place
for safety.
Adds AggressiveDCETest.KeepDebugBuildIdentifier to verify that
DebugBuildIdentifier and its transitive operands (OpTypeInt, OpConstant)
are preserved and the output remains valid after ADCE runs.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@jkwak-work
Copy link
Copy Markdown
Contributor Author

@SteveUrquhart , can you re-review this PR?
I added the test as you instructed.

@jkwak-work
Copy link
Copy Markdown
Contributor Author

Fixes #6619

jkwak-work added a commit to jkwak-work/slang that referenced this pull request Apr 3, 2026
This PR includes the latest SPIRV-Tools and the matching SPIRV-Headers.

This PR also includes a spirv-opt fix that is currently in a review
process:
  KhronosGroup/SPIRV-Tools#6626
github-merge-queue Bot pushed a commit to shader-slang/slang that referenced this pull request Apr 3, 2026
This PR includes the latest SPIRV-Tools and the matching SPIRV-Headers.

This PR also includes a spirv-opt fix that is currently in a review
process:
  KhronosGroup/SPIRV-Tools#6626
github-merge-queue Bot pushed a commit to shader-slang/slang that referenced this pull request Apr 3, 2026
This PR includes the latest SPIRV-Tools and the matching SPIRV-Headers.

This PR also includes a spirv-opt fix that is currently in a review
process:
  KhronosGroup/SPIRV-Tools#6626
@s-perron s-perron enabled auto-merge (squash) April 8, 2026 15:48
@jkwak-work
Copy link
Copy Markdown
Contributor Author

@s-perron , I resolved the merge conflict.
Can you approve the workflows?

auto-merge was automatically disabled April 20, 2026 21:47

Head branch was pushed to by a user without write access

@jkwak-work
Copy link
Copy Markdown
Contributor Author

@s-perron , sorry, I had to re-resolve the merge-conflict.
Can you approve the workflows again?
Thanks

@s-perron s-perron enabled auto-merge (squash) April 20, 2026 22:25
@jkwak-work
Copy link
Copy Markdown
Contributor Author

@s-perron , I am not sure what is happening.
It seems like it still needs approval for the workflows.

@s-perron s-perron merged commit 706f1dc into KhronosGroup:main Apr 20, 2026
25 checks passed
kaizhangNV added a commit to kaizhangNV/slang that referenced this pull request Apr 23, 2026
Update SPIRV-Tools to ff5c5033 (origin/main) and SPIRV-Headers to
ad9184e (origin/main). The previous spirv-tools pointed to a fork with
custom patches for DebugBuildIdentifier in ADCE; those fixes have since
been merged upstream (KhronosGroup/SPIRV-Tools#6626), so we can now
point directly to upstream main.

Notable upstream changes:
- spirv-val: Add validation for 4-bit integer types
- spirv-val: Handle OpSpecConstantDataKHR / OpConstantDataKHR
- spirv-opt: Fix DebugValue placements
- spirv-as: Fix OpConstantDataKHR new grammar
- Add support for SPV_KHR_abort and SPV_KHR_constant_data
- Add validation for NSDI 101

Made-with: Cursor
kaizhangNV added a commit to kaizhangNV/slang that referenced this pull request Apr 24, 2026
Update SPIRV-Tools to ff5c5033 (origin/main) and SPIRV-Headers to
ad9184e (origin/main). The previous spirv-tools pointed to a fork with
custom patches for DebugBuildIdentifier in ADCE; those fixes have since
been merged upstream (KhronosGroup/SPIRV-Tools#6626), so we can now
point directly to upstream main.

Notable upstream changes:
- spirv-val: Add validation for 4-bit integer types
- spirv-val: Handle OpSpecConstantDataKHR / OpConstantDataKHR
- spirv-opt: Fix DebugValue placements
- spirv-as: Fix OpConstantDataKHR new grammar
- Add support for SPV_KHR_abort and SPV_KHR_constant_data
- Add validation for NSDI 101

Made-with: Cursor
jkwak-work pushed a commit to jkwak-work/slang that referenced this pull request Apr 24, 2026
…#10929)

## Summary

- Update SPIRV-Tools submodule to `ff5c5033` (upstream `main`) and
SPIRV-Headers to `ad9184e` (upstream `main`)
- The previous SPIRV-Tools pointed to a fork with custom patches for
DebugBuildIdentifier in ADCE; those fixes have since been merged
upstream
([KhronosGroup/SPIRV-Tools#6626](KhronosGroup/SPIRV-Tools#6626)),
so we now point directly to upstream main
- Regenerated `external/spirv-tools-generated/` files to match

### Notable upstream SPIRV-Tools changes (21 commits):
- spirv-val: Add validation for 4-bit integer types (shader-slang#6644)
- spirv-val: Handle OpSpecConstantDataKHR (shader-slang#6646)
- spirv-val: Validate OpConstantDataKHR (shader-slang#6643)
- spirv-opt: Fix DebugValue placements (shader-slang#6599)
- spirv-as: Fix OpConstantDataKHR new grammar (shader-slang#6642)
- Add support for SPV_KHR_abort and SPV_KHR_constant_data (shader-slang#6625)
- Add validation for NSDI 101 (shader-slang#6635)
- Fix crash in shuffle validation (shader-slang#6645)
- spirv-opt: add missing OpConstantCompositeReplicateEXT support to
constant manager (shader-slang#6616)

### Notable upstream SPIRV-Headers changes (4 commits):
- Fix constant data operand types (shader-slang#581)
- Add NSDI 101 instructions and version bump (shader-slang#579)
- Add version-unified grammar and header for
NonSemantic.Shader.DebugInfo (shader-slang#578)
- [Bazel] Add NonSemanticDebugBreak.h to the common headers (shader-slang#577)

## Test plan
- [x] Builds successfully on Linux (Release)
- [x] CI passes

Made with [Cursor](https://cursor.com)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants