Fix crash when heap subscript result is discarded - #8749
Open
Chris B (llvm-beanz) wants to merge 3 commits into
Open
Fix crash when heap subscript result is discarded#8749Chris B (llvm-beanz) wants to merge 3 commits into
Chris B (llvm-beanz) wants to merge 3 commits into
Conversation
Without this change DXC crashes if the result of a descriptor heap subscript is discarded. The crash is caused by not correctly handling lifetime marker intrinsics when rewriting resources that otherwise have no uses. The fix here ignores bitcasts to i8* which are associated with lifetime markers when rewriting resource accesses. This fix is a targeted "avoid the crash" fix, rather than wholistic since this rewriting _really_ shouldn't be happening at the end of IR generation, it should likely be in a separate IR pass. Assisted by: Copilot, Claude Sonnet 5. ../tools/clang/test/CodeGenDXIL/discarded_dynamic_res.hlsl
Contributor
There was a problem hiding this comment.
Pull request overview
Prevents DXC from crashing when discarded descriptor-heap subscripts leave lifetime-marker-only resource uses.
Changes:
- Preserves lifetime-marker bitcasts during resource rewriting.
- Adds regression coverage for resource and sampler heaps.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
tools/clang/lib/CodeGen/CGHLSLMSFinishCodeGen.cpp |
Handles lifetime-only bitcasts safely. |
tools/clang/test/CodeGenDXIL/discarded_dynamic_res.hlsl |
Tests discarded heap subscript expressions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // later legalization passes (which already know how to handle | ||
| // bitcasts that are onlyUsedByLifetimeMarkers) will clean them up | ||
| // once resPtr has no other real uses. | ||
| if (BCI->getType()->getPointerElementType()->isIntegerTy(8)) { |
Damyan Pepper (damyanp)
approved these changes
Aug 10, 2026
Joshua Batista (bob80905)
approved these changes
Aug 10, 2026
Joshua Batista (bob80905)
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. Only nit is that the comments could be seen as verbose.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (1)
docs/ReleaseNotes.md:35
CONTRIBUTING.md:136-140requires release-note entries to be a single sentence and not link to specific PRs. This entry uses two sentences and links to a discussion on PR #8517; please condense it and remove the PR link.
- Fix a crash generating DXIL from sources containing a dynamic resource heap
access that was discarded. Identified during development of SPIR-V support for
[descriptor heaps](https://github.com/microsoft/DirectXShaderCompiler/pull/8517#discussion_r3752113078).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Without this change DXC crashes if the result of a descriptor heap subscript is discarded. The crash is caused by not correctly handling lifetime marker intrinsics when rewriting resources that otherwise have no uses.
The fix here ignores bitcasts to i8* which are associated with lifetime markers when rewriting resource accesses.
This fix is a targeted "avoid the crash" fix, rather than wholistic since this rewriting really shouldn't be happening at the end of IR generation, it should likely be in a separate IR pass.
Assisted by: Copilot, Claude Sonnet 5.