Skip to content

Conversation

@spall
Copy link
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
Contributor

github-actions bot commented Dec 18, 2025

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 60a1c8568b405bbe9f47ab0431f627ef64988cc4 a6f890ea130e7f749b280123e78ec8ed987e9efa -- lib/HLSL/HLLegalizeParameter.cpp tools/clang/include/clang/AST/Decl.h tools/clang/include/clang/Basic/Specifiers.h tools/clang/lib/AST/HlslTypes.cpp tools/clang/lib/AST/MicrosoftMangle.cpp tools/clang/lib/CodeGen/CGHLSLMS.cpp tools/clang/lib/Sema/SemaDeclAttr.cpp tools/clang/lib/Sema/SemaHLSL.cpp tools/clang/lib/Sema/SemaOverload.cpp
View the diff from clang-format here.
diff --git a/tools/clang/lib/AST/MicrosoftMangle.cpp b/tools/clang/lib/AST/MicrosoftMangle.cpp
index 1532f441..35cbb7cd 100644
--- a/tools/clang/lib/AST/MicrosoftMangle.cpp
+++ b/tools/clang/lib/AST/MicrosoftMangle.cpp
@@ -2035,7 +2035,8 @@ void MicrosoftCXXNameMangler::mangleType(const LValueReferenceType *T,
                                          Qualifiers Quals, SourceRange Range) {
   QualType PointeeType = T->getPointeeType();
   Out << (Quals.hasVolatile() ? 'B' : 'A');
-  if (PointeeType.getQualifiers().getAddressSpace() == hlsl::DXIL::kTGSMAddrSpace)
+  if (PointeeType.getQualifiers().getAddressSpace() ==
+      hlsl::DXIL::kTGSMAddrSpace)
     Out << 'G';
   manglePointerExtQualifiers(Quals, PointeeType);
   mangleType(PointeeType, Range);
diff --git a/tools/clang/lib/Sema/SemaHLSL.cpp b/tools/clang/lib/Sema/SemaHLSL.cpp
index cc27854c..46ab3a51 100644
--- a/tools/clang/lib/Sema/SemaHLSL.cpp
+++ b/tools/clang/lib/Sema/SemaHLSL.cpp
@@ -15771,7 +15771,9 @@ bool Sema::DiagnoseHLSLDecl(Declarator &D, DeclContext *DC, Expr *BitWidth,
         Diag(pAttr->getLoc(), diag::warn_hlsl_groupshared_202x);
       if (isParameter && (usageIn || usageOut)) {
         Diag(pAttr->getLoc(), diag::err_hlsl_varmodifiersna)
-	  << (usageIn && usageOut ? "'inout'" : usageIn ? "'in'" : "'out'")
+            << (usageIn && usageOut ? "'inout'"
+                : usageIn           ? "'in'"
+                                    : "'out'")
             << pAttr->getName() << declarationType;
         result = false;
       }
  • Check this box to apply formatting changes to this branch.

Copy link
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.

@damyanp
Copy link
Member

damyanp commented Jan 12, 2026

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

Copy link
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!

- Header file `dxcpix.h` was added to the release package.
- Moved Linear Algebra (Cooperative Vector) DXIL Opcodes to experimental Shader Model 6.10
- Added support for `long long` and `unsigned long long` compile-time constant evaluation, fixes [#7952](https://github.com/microsoft/DirectXShaderCompiler/issues/7952).
- Added support for the groupshared attribute for parameters to Shader Model 6.10
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it would be good to start a habit of linking the PR with the note? I like the idea.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't have a preference although I'd be inclined to follow the seeming convention of not including, unless you can find further support for this change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Some of the items link issues. Some link PRs (the highlights for 1.8.2502). Others do nothing. Just seems random.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Some of the items link issues. Some link PRs (the highlights for 1.8.2502). Others do nothing. Just seems random.

ok i guess the ones i looked at didn't link, but i must have missed some.

const bool IsRCAttr = isa<HLSLReorderCoherentAttr>(A);
const bool IsExportAttr = isa<HLSLExportAttr>(A);
const bool IsNoInlineAttr = isa<NoInlineAttr>(A);
if (IsExportAttr || IsNoInlineAttr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can remove an indentation level by just retrning early if neither condition is true

Suggested change
if (IsExportAttr || IsNoInlineAttr) {
if (!IsExportAttr || !IsNoInlineAttr)
return;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The function doesn't return if this is false.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the if statement should probably not be returning either.

Copy link
Contributor

Choose a reason for hiding this comment

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

The function doesn't return if this is false.

🤦‍♂️

Diag(pAttr->getLoc(), diag::err_hlsl_usage_not_on_parameter)
<< pAttr->getName() << pAttr->getRange();
result = false;
} else if (isGroupShared) {
Copy link

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
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.

handleSimpleAttribute<NoDuplicateAttr>(S, D, Attr);
break;
case AttributeList::AT_NoInline:
if (S.LangOpts.HLSL) {
Copy link

Choose a reason for hiding this comment

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

I am not quite sure I understand this change. Would we otherwise not parse the attributes of the parameter without this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the basic handling wouldn't check if a parameter of a function with the noinline attribute has the groupshared attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

Implement support for groupshared arguments in 202x

5 participants