Repository navigation
Emit valid debug info for LinAlg matrix handles - #9187
Open
Damyan Pepper (damyanp) wants to merge 2 commits into
Open
Damyan Pepper (damyanp) wants to merge 2 commits into
Damyan Pepper (damyanp) wants to merge 2 commits into
Conversation
CGDebugInfo::CreateType(const BuiltinType *) had no case for BuiltinType::LinAlgMatrix, so the DWARF encoding passed to createBasicType was uninitialized. Depending on build and optimization level this produced garbage encodings that LLParser rejects (limit 255), breaking disassemble/reassemble of any -Zi shader that uses a LinAlg matrix, whether as a local, parameter, array element, struct member or through the dx::linalg::Matrix wrapper. Describe the handle as an opaque, memberless structure sized from the ASTContext, initialize the encoding, and assert that every builtin reaching createBasicType has one. Fixes microsoft#9183 Co-authored-by: Copilot App <[email protected]>
| break; | ||
| } | ||
| // HLSL Change - catch builtins that were given no debug encoding. | ||
| assert(Encoding != 0 && "Unhandled builtin type in debug info"); |
Collaborator
There was a problem hiding this comment.
Why not add a default case that is llvm_unreachable or just enable the compiler warning so that warning as errors flags this?
Member
Author
There was a problem hiding this comment.
Switched to llvm_unreachable. Considering enabling the compiler warning, but this'll generate 138 warnings, will consider this in a followup.
Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The FileCheck negative assertions leave gaps between DAG matches, allowing an unwanted __builtin_LinAlgMatrix DIBasicType to escape detection.
1 open issue
What changed in this PR
Fixes #9183 by giving LinAlg matrix handles valid, opaque debug metadata so disassembled DXIL can be reassembled.
Changes:
- Represents matrix handles as memberless structs and rejects unhandled builtin types.
- Adds debug-metadata, assembler round-trip, and PIX offset tests.
- Documents the fix in release notes.
| File | Description |
|---|---|
tools/clang/test/CodeGenDXIL/hlsl/linalg/linalg-matrix-debug-info.hlsl |
Adds regression coverage for matrix debug information. |
tools/clang/lib/CodeGen/CGDebugInfo.cpp |
Emits opaque matrix types and guards builtin handling. |
docs/ReleaseNotes.md |
Records the debug-information fix. |
Review effort: Balanced
| // RUN: FileCheck %s --check-prefix=CHECK < %t.o3.ll | ||
| // RUN: %dxa %t.o3.ll -o %t.o3.dxil | ||
|
|
||
| // RUN: %dxc -T cs_6_10 -E main -fcgl -Zi -enable-16bit-types %s | FileCheck %s --check-prefix=SHAPES |
This branch has not been deployed
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.

CGDebugInfo had no case for
__builtin_LinAlgMatrix, so it passed an uninitialized DWARF encoding to createBasicType. Any-Zishader using a LinAlg matrix could emit debug metadata that fails to reassemble.Describe the matrix as an opaque, memberless struct so debuggers treat it like other opaque handles. Add a
default: llvm_unreachableto the encoding switch, because DXC disables-Wswitchand nothing else would catch the next unhandled builtin.Fixes #9183
Assisted-by: Copilot