diff --git a/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td b/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td index 9692a8dc6a..a7525ad5b8 100644 --- a/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -7818,6 +7818,8 @@ def err_hlsl_maxrecursiondepth_exceeded : Error< "NodeMaxRecursionDepth may not exceed 32">; def err_hlsl_too_many_node_inputs : Error< "Node shader '%0' may not have more than one input record">; +def err_hlsl_incompatible_param_attr : Error< + "parameter '%0' may not have both '%1' and '%2'">; // HLSL Change Ends // SPIRV Change Starts diff --git a/tools/clang/lib/CodeGen/CGHLSLMS.cpp b/tools/clang/lib/CodeGen/CGHLSLMS.cpp index f3d0343cde..3f9f4b688c 100644 --- a/tools/clang/lib/CodeGen/CGHLSLMS.cpp +++ b/tools/clang/lib/CodeGen/CGHLSLMS.cpp @@ -2523,14 +2523,8 @@ void CGMSHLSLRuntime::AddHLSLFunctionInfo(Function *F, const FunctionDecl *FD) { } node.MaxRecordsSharedWith = ix; } - if (const auto *Attr = parmDecl->getAttr()) { - if (node.MaxRecordsSharedWith >= 0) { - Diags.Report(parmDecl->getLocation(), Diags.getCustomDiagID( - DiagnosticsEngine::Error, - "Only one of MaxRecords or MaxRecordsSharedWith may be specified to the same parameter.")); - } + if (const auto *Attr = parmDecl->getAttr()) node.MaxRecords = Attr->getMaxCount(); - } } if (inputPatchCount > 1) { diff --git a/tools/clang/lib/Sema/SemaHLSL.cpp b/tools/clang/lib/Sema/SemaHLSL.cpp index 453ad2f6cd..6ef9ff4144 100644 --- a/tools/clang/lib/Sema/SemaHLSL.cpp +++ b/tools/clang/lib/Sema/SemaHLSL.cpp @@ -11462,6 +11462,12 @@ class WorkGraphVisitor : public RecursiveASTVisitor { << funcName << P->getSourceRange(); } } + // MaxRecords and MaxRecordsSharedWith are mutually exclusive + if (auto *maxShared = P->getAttr()) + if (auto *maxRecs = P->getAttr()) + S.Diags.Report(P->getLocation(), diag::err_hlsl_incompatible_param_attr) + << P->getName() << maxShared->getSpelling() << maxRecs->getSpelling() + << P->getSourceRange(); return true; } diff --git a/tools/clang/test/HLSL/workgraph/node_input_compatibility.hlsl b/tools/clang/test/HLSL/workgraph/node_input_compatibility.hlsl index aab5421a9b..06ad15df16 100644 --- a/tools/clang/test/HLSL/workgraph/node_input_compatibility.hlsl +++ b/tools/clang/test/HLSL/workgraph/node_input_compatibility.hlsl @@ -113,3 +113,9 @@ void node17(ThreadNodeInputRecord input, NodeOutput output, RWThreadNodeInputRecord input2) // expected-error {{Node shader 'node17' may not have more than one input record}} { } + +[Shader("node")] +[NodeLaunch("thread")] +void node18(NodeOutput firstOut, + [MaxRecords(5)][MaxRecordsSharedWith(firstOut)] NodeOutput secondOut) // expected-error {{parameter 'secondOut' may not have both 'maxrecordssharedwith' and 'MaxRecords'}} +{ } diff --git a/tools/clang/test/HLSLFileCheck/hlsl/workgraph/case092_maxoutputrecords_maxoutputrecordssharedwith.hlsl b/tools/clang/test/HLSLFileCheck/hlsl/workgraph/case092_maxoutputrecords_maxoutputrecordssharedwith.hlsl deleted file mode 100644 index 3a1f4487ab..0000000000 --- a/tools/clang/test/HLSLFileCheck/hlsl/workgraph/case092_maxoutputrecords_maxoutputrecordssharedwith.hlsl +++ /dev/null @@ -1,28 +0,0 @@ -// RUN: %dxc -T lib_6_8 %s | FileCheck %s -// ================================================================== -// CASE092 (fail) -// MaxRecords and MaxRecordsSharedWith are both declared -// ================================================================== - -struct INPUT_RECORD -{ - uint value; -}; - -struct OUTPUT_RECORD -{ - uint num; -}; - -[Shader("node")] -[NodeLaunch("Broadcasting")] -[NodeDispatchGrid(256,1,1)] -[NumThreads(1,1,1)] -[NodeIsProgramEntry] -void node092_maxoutputrecords_maxoutputrecordssharedwith(DispatchNodeInputRecord input, - [MaxRecords(5)] NodeOutput firstOut, - [MaxRecords(5)][MaxRecordsSharedWith(firstOut)] NodeOutput secondOut) -{ -} - -// CHECK: 24:132: error: Only one of MaxRecords or MaxRecordsSharedWith may be specified to the same parameter diff --git a/tools/clang/test/HLSLFileCheck/shader_targets/nodes/max_output_records_duplicate1.hlsl b/tools/clang/test/HLSLFileCheck/shader_targets/nodes/max_output_records_duplicate1.hlsl index c8553a9222..7f346385e3 100644 --- a/tools/clang/test/HLSLFileCheck/shader_targets/nodes/max_output_records_duplicate1.hlsl +++ b/tools/clang/test/HLSLFileCheck/shader_targets/nodes/max_output_records_duplicate1.hlsl @@ -3,10 +3,10 @@ // Duplicate MaxRecords info with matching limits -// CHECK: 28:68: error: Only one of MaxRecords or MaxRecordsSharedWith may be specified to the same parameter. -// CHECK: 29:68: error: Only one of MaxRecords or MaxRecordsSharedWith may be specified to the same parameter. -// CHECK: 30:68: error: Only one of MaxRecords or MaxRecordsSharedWith may be specified to the same parameter. -// CHECK: 31:68: error: Only one of MaxRecords or MaxRecordsSharedWith may be specified to the same parameter. +// CHECK: 28:68: error: parameter 'Output2' may not have both 'maxrecordssharedwith' and 'MaxRecords' +// CHECK: 29:68: error: parameter 'Output3' may not have both 'maxrecordssharedwith' and 'MaxRecords' +// CHECK: 30:68: error: parameter 'Output4' may not have both 'maxrecordssharedwith' and 'MaxRecords' +// CHECK: 31:68: error: parameter 'Output5' may not have both 'maxrecordssharedwith' and 'MaxRecords' struct rec0 { diff --git a/tools/clang/test/HLSLFileCheck/shader_targets/nodes/max_output_records_duplicate2.hlsl b/tools/clang/test/HLSLFileCheck/shader_targets/nodes/max_output_records_duplicate2.hlsl index eb6ee30ff4..5fc106034f 100644 --- a/tools/clang/test/HLSLFileCheck/shader_targets/nodes/max_output_records_duplicate2.hlsl +++ b/tools/clang/test/HLSLFileCheck/shader_targets/nodes/max_output_records_duplicate2.hlsl @@ -2,10 +2,10 @@ // Duplicate MaxRecords info with mismatching limits -// CHECK: 27:68: error: Only one of MaxRecords or MaxRecordsSharedWith may be specified to the same parameter. -// CHECK: 28:68: error: Only one of MaxRecords or MaxRecordsSharedWith may be specified to the same parameter. -// CHECK: 29:68: error: Only one of MaxRecords or MaxRecordsSharedWith may be specified to the same parameter. -// CHECK: 30:68: error: Only one of MaxRecords or MaxRecordsSharedWith may be specified to the same parameter. +// CHECK: 27:68: error: parameter 'Output2' may not have both 'maxrecordssharedwith' and 'MaxRecords' +// CHECK: 28:68: error: parameter 'Output3' may not have both 'maxrecordssharedwith' and 'MaxRecords' +// CHECK: 29:68: error: parameter 'Output4' may not have both 'maxrecordssharedwith' and 'MaxRecords' +// CHECK: 30:68: error: parameter 'Output5' may not have both 'maxrecordssharedwith' and 'MaxRecords' struct rec0 {