[LinAlg] Disallow linalg types in cbuffers and gs - #8969
Open
Chris B (llvm-beanz) wants to merge 2 commits into
Open
Chris B (llvm-beanz) wants to merge 2 commits into
Chris B (llvm-beanz) wants to merge 2 commits into
Conversation
This change disallows linalg objects in groupshared memory and in cbuffers. A global of any type containing a linalg handle must be marked `static`. Assisted-by: GitHub Copilot
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Explicit ConstantBuffer<T> and TextureBuffer<T> declarations still permit structs containing LinAlg handles.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Restricts LinAlg matrix handles to valid storage contexts while preserving explicit static globals.
Changes:
- Rejects non-static globals and groupshared LinAlg values.
- Adds diagnostics and semantic/code-generation coverage.
- Updates existing builtin and AST tests.
| File | Description |
|---|---|
tools/clang/lib/Sema/SemaHLSL.cpp |
Implements storage validation. |
tools/clang/include/clang/Basic/DiagnosticSemaKinds.td |
Adds the global diagnostic. |
tools/clang/test/SemaHLSL/hlsl/linalg/linalg-matrix-global-error.hlsl |
Tests invalid storage contexts. |
tools/clang/test/SemaHLSL/hlsl/linalg/builtins/builtin-matrix-handle-type.hlsl |
Updates builtin-handle diagnostics. |
tools/clang/test/SemaHLSL/hlsl/linalg/builtins/builtin-matrix-handle-type-ast.hlsl |
Makes the AST test global static. |
tools/clang/test/CodeGenDXIL/hlsl/linalg/linalg-matrix-global.hlsl |
Verifies static-global lowering. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Ashley Coleman (V-FEXrt)
approved these changes
Sep 25, 2026
Damyan Pepper (damyanp)
approved these changes
Sep 25, 2026
Damyan Pepper (damyanp)
left a comment
Member
There was a problem hiding this comment.
Nit on param names (although I'm unsure what the llvm coding guidelines has to say about them, so maybe it's wrong).
Looks like the copilot feedback about ConstantBuffer<T> might be worth considering.
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.


This change disallows linalg objects in groupshared memory and in cbuffers. A global of any type containing a linalg handle must be marked
static.Assisted-by: GitHub Copilot