Enable groupshared arg on templates + tests#8217
Open
spall wants to merge 2 commits intomicrosoft:mainfrom
Open
Enable groupshared arg on templates + tests#8217spall wants to merge 2 commits intomicrosoft:mainfrom
spall wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Contributor
You can test this locally with the following command:git-clang-format --diff d4b2d044f150c5bf9ac056fcacb2a30df54b5d93 c1a417eeb59db3dfc459bb1d62220cf1f5e53d77 -- tools/clang/lib/Sema/SemaDecl.cpp tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cppView the diff from clang-format here.diff --git a/tools/clang/lib/Sema/SemaDecl.cpp b/tools/clang/lib/Sema/SemaDecl.cpp
index b1069551..b07d4a9a 100644
--- a/tools/clang/lib/Sema/SemaDecl.cpp
+++ b/tools/clang/lib/Sema/SemaDecl.cpp
@@ -10460,10 +10460,10 @@ ParmVarDecl *Sema::CheckParameter(DeclContext *DC, SourceLocation StartLoc,
// OpenCL allows function arguments declared to be an array of a type
// to be qualified with an address space.
if (!(getLangOpts().OpenCL && T->isArrayType()) &&
- // HLSL allows parameters to be qualified with the groupshared
- // address space.
- !(getLangOpts().HLSL && T.getAddressSpace() ==
- hlsl::DXIL::kTGSMAddrSpace)) {
+ // HLSL allows parameters to be qualified with the groupshared
+ // address space.
+ !(getLangOpts().HLSL &&
+ T.getAddressSpace() == hlsl::DXIL::kTGSMAddrSpace)) {
Diag(NameLoc, diag::err_arg_with_address_space);
New->setInvalidDecl();
}
diff --git a/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 571c6e49..c3cd903a 100644
--- a/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -269,12 +269,12 @@ void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
}
if (isa<HLSLGroupSharedAttr>(TmplAttr)) {
- // the type wasn't set properly before so we need to instantiate this type as
- // a groupshared reference
+ // the type wasn't set properly before so we need to instantiate this type
+ // as a groupshared reference
ParmVarDecl *NewParm = cast<ParmVarDecl>(New);
NewParm->addAttr(TmplAttr->clone(getASTContext()));
- NewParm->setType(Context.getAddrSpaceQualType(NewParm->getType(),
- hlsl::DXIL::kTGSMAddrSpace));
+ NewParm->setType(Context.getAddrSpaceQualType(
+ NewParm->getType(), hlsl::DXIL::kTGSMAddrSpace));
NewParm->setType(Context.getLValueReferenceType(NewParm->getType()));
continue;
}
|
bob80905
approved these changes
Mar 4, 2026
inbelic
reviewed
Mar 4, 2026
| // expected-error@-1{{'template' is a reserved keyword in HLSL}} | ||
| template [noinline] void fn3<float>(groupshared float A, groupshared float B); | ||
| // expected-error@-1{{use of undeclared identifier 'noinline'}} | ||
| // expected-error@-2{{expected unqualified-id}} No newline at end of file |
| [numthreads(4, 1, 1)] | ||
| void main(uint3 TID : SV_GroupThreadID) { | ||
| fn1(SharedData); | ||
| tfoo<int4>(SharedData1); |
There was a problem hiding this comment.
Do we expect something like tfoo<uint4>(SharedData1) to be valid?
edit: I see we don't allow uint16_t to half below
Collaborator
Author
There was a problem hiding this comment.
yeah casting isn't allowed.
inbelic
approved these changes
Mar 5, 2026
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.
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.