Skip to content

Implement support for groupshared arg attribute#8013

Merged
spall merged 15 commits intomicrosoft:mainfrom
spall:issue-7969
Jan 20, 2026
Merged

Implement support for groupshared arg attribute#8013
spall merged 15 commits intomicrosoft:mainfrom
spall:issue-7969

Conversation

@spall
Copy link
Copy Markdown
Collaborator

@spall spall commented Dec 18, 2025

Implements support for groupshared argument attribute.
Closes #7969

spall added 4 commits December 3, 2025 16:37
get compiler to error when types aren't exactly the same + arg not groupshared

bug fix

fix test

disallow groupshared param in export/noinline funcs

first check if there are attrs

remove accidental change

tests
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 18, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Copy Markdown
Member

@hekota hekota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good, I just have a few comments and suggestions/nits.

Comment thread tools/clang/test/SemaHLSL/v202x/groupshared/ScalarTest.hlsl Outdated
Comment thread tools/clang/test/SemaHLSL/v202x/groupshared/NotGroupSharedTest.hlsl Outdated
Comment thread tools/clang/test/SemaHLSL/v202x/groupshared/NotGroupSharedTest.hlsl Outdated
Comment thread tools/clang/test/SemaHLSL/v202x/groupshared/InOutWarning.hlsl Outdated
Comment thread tools/clang/test/CodeGenHLSL/groupsharedArgs/TemplateTest.hlsl
Comment thread tools/clang/test/CodeGenHLSL/groupsharedArgs/Overloads.hlsl
Comment thread tools/clang/test/CodeGenHLSL/groupsharedArgs/ScalarTest.hlsl Outdated
Comment thread tools/clang/lib/AST/HlslTypes.cpp
Comment thread tools/clang/lib/Sema/SemaHLSL.cpp Outdated
Comment thread tools/clang/include/clang/AST/Decl.h Outdated
@damyanp
Copy link
Copy Markdown
Member

damyanp commented Jan 12, 2026

Please add something to https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/ReleaseNotes.md as appropriate.

Copy link
Copy Markdown
Member

@hekota hekota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment thread docs/ReleaseNotes.md Outdated
Comment thread tools/clang/lib/Sema/SemaHLSL.cpp
Comment thread lib/HLSL/HLLegalizeParameter.cpp Outdated
Comment thread tools/clang/lib/AST/MicrosoftMangle.cpp Outdated
Diag(pAttr->getLoc(), diag::err_hlsl_usage_not_on_parameter)
<< pAttr->getName() << pAttr->getRange();
result = false;
} else if (isGroupShared) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it guaranteed that groupshared will be processed/specified before inout?

Otherwise, we might need to handle the opposite case above

Copy link
Copy Markdown
Collaborator Author

@spall spall Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the cases for inout and for groupshared I think it is handled regardless of order, but good point and I think this points to a test is missing for this.

Comment thread tools/clang/lib/Sema/SemaDeclAttr.cpp
Comment thread tools/clang/include/clang/Basic/DiagnosticSemaKinds.td Outdated
Comment thread docs/ReleaseNotes.md
- GetGroupWaveCount: New intrinsic for Compute, Mesh, Amplification and Node
shaders which returns the total number of waves executing within the thread
group.
- Added support for `long long` and `unsigned long long` compile-time constant evaluation, fixes [#7952](https://github.com/microsoft/DirectXShaderCompiler/issues/7952).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the right note? Doesn't seem related to this PR. I don't think it is related to experimental SM 6.10 either, so should probably go in the Other Changes section.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh no i didn't see this was changed and this comment before i pushed merge. i will fix this in follow up now. I guess the conflict resolution for this file didn't go correctly.

@spall spall merged commit ab0c968 into microsoft:main Jan 20, 2026
12 checks passed
@github-project-automation github-project-automation Bot moved this from New to Done in HLSL Roadmap Jan 20, 2026
spall added a commit to spall/DirectXShaderCompiler that referenced this pull request Jan 20, 2026
spall added a commit that referenced this pull request Jan 21, 2026
Fix the release notes incorrectly modified in #8013
spall added a commit that referenced this pull request Mar 9, 2026
As a follow up to #8013 and issue #7969, add support for the use of the
groupshared parameter attribute in templates.
Adds new tests showing codegen and updates existing Sema tests to show
relevant errors produced.

```
template<typename T>
T fn(groupshared T A) {
  return A;
}
```

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Implement support for groupshared arguments in 202x

5 participants