[clang] Warns that the WaveSize attribute is unsupported for the SPIR-V target. (PR #196004)
via cfe-commits
cfe-commits at lists.llvm.org
Tue May 5 23:27:39 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Dan Brown (danbrown-amd)
<details>
<summary>Changes</summary>
Addresses #<!-- -->187188.
---
Full diff: https://github.com/llvm/llvm-project/pull/196004.diff
2 Files Affected:
- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+4)
- (modified) clang/lib/Sema/SemaHLSL.cpp (+3-1)
``````````diff
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e059260778631..e95d9ef58e9dd 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -13703,6 +13703,10 @@ def warn_attr_min_eq_max: Warning<
def err_hlsl_attribute_number_arguments_insufficient_shader_model: Error<
"attribute %0 with %1 arguments requires shader model %2 or greater">;
+def warn_hlsl_wavesize_unsupported_spirv : Warning<
+ "attribute 'WaveSize' is not supported for the SPIR-V target; "
+ "consider using VK_EXT_subgroup_size_control">,
+ InGroup<HLSLAttributeStatement>;
def err_hlsl_expect_arg_const_int_one_or_neg_one: Error<
"argument %0 must be constant integer 1 or -1">;
def err_invalid_hlsl_resource_type: Error<
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index aba1c5072a5fc..a33e54d15ba2a 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -1000,7 +1000,9 @@ void SemaHLSL::CheckEntryPoint(FunctionDecl *FD) {
FD->setInvalidDecl();
}
if (const auto *WS = FD->getAttr<HLSLWaveSizeAttr>()) {
- if (Ver < VersionTuple(6, 6)) {
+ if (TargetInfo.getTriple().isSPIRV()) {
+ Diag(WS->getLocation(), diag::warn_hlsl_wavesize_unsupported_spirv);
+ } else if (Ver < VersionTuple(6, 6)) {
Diag(WS->getLocation(), diag::err_hlsl_attribute_in_wrong_shader_model)
<< WS << "6.6";
FD->setInvalidDecl();
``````````
</details>
https://github.com/llvm/llvm-project/pull/196004
More information about the cfe-commits
mailing list