-
Notifications
You must be signed in to change notification settings - Fork 827
Implement support for groupshared arg attribute #8013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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
update tests to show new mangling
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.cppView 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;
}
|
hekota
left a comment
There was a problem hiding this 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.
tools/clang/test/SemaHLSL/v202x/groupshared/NotGroupSharedTest.hlsl
Outdated
Show resolved
Hide resolved
tools/clang/test/SemaHLSL/v202x/groupshared/NotGroupSharedTest.hlsl
Outdated
Show resolved
Hide resolved
|
Please add something to https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/ReleaseNotes.md as appropriate. |
hekota
left a comment
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
| if (IsExportAttr || IsNoInlineAttr) { | |
| if (!IsExportAttr || !IsNoInlineAttr) | |
| return; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Implements support for groupshared argument attribute.
Closes #7969