Skip to content

Commit f3f7419

Browse files
author
Tim Corringham
committed
Move MaxRecords vs MaxRecordsSharedWith diagnostic
A node output parameter may not have both the MaxRecords and MaxRecordsShared with attribute. Moved the error diagnostic for this case from CodeGen to Sema, and replaced the FileCheck test with a verifier test case.
1 parent 680ab66 commit f3f7419

File tree

7 files changed

+23
-43
lines changed

7 files changed

+23
-43
lines changed

tools/clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7818,6 +7818,8 @@ def err_hlsl_maxrecursiondepth_exceeded : Error<
78187818
"NodeMaxRecursionDepth may not exceed 32">;
78197819
def err_hlsl_too_many_node_inputs : Error<
78207820
"Node shader '%0' may not have more than one input record">;
7821+
def err_hlsl_incompatible_param_attr : Error<
7822+
"parameter '%0' may not have both '%1' and '%2'">;
78217823
// HLSL Change Ends
78227824

78237825
// SPIRV Change Starts

tools/clang/lib/CodeGen/CGHLSLMS.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2523,14 +2523,8 @@ void CGMSHLSLRuntime::AddHLSLFunctionInfo(Function *F, const FunctionDecl *FD) {
25232523
}
25242524
node.MaxRecordsSharedWith = ix;
25252525
}
2526-
if (const auto *Attr = parmDecl->getAttr<HLSLMaxRecordsAttr>()) {
2527-
if (node.MaxRecordsSharedWith >= 0) {
2528-
Diags.Report(parmDecl->getLocation(), Diags.getCustomDiagID(
2529-
DiagnosticsEngine::Error,
2530-
"Only one of MaxRecords or MaxRecordsSharedWith may be specified to the same parameter."));
2531-
}
2526+
if (const auto *Attr = parmDecl->getAttr<HLSLMaxRecordsAttr>())
25322527
node.MaxRecords = Attr->getMaxCount();
2533-
}
25342528
}
25352529

25362530
if (inputPatchCount > 1) {

tools/clang/lib/Sema/SemaHLSL.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11462,6 +11462,12 @@ class WorkGraphVisitor : public RecursiveASTVisitor<WorkGraphVisitor> {
1146211462
<< funcName << P->getSourceRange();
1146311463
}
1146411464
}
11465+
// MaxRecords and MaxRecordsSharedWith are mutually exclusive
11466+
if (auto *maxShared = P->getAttr<HLSLMaxRecordsSharedWithAttr>())
11467+
if (auto *maxRecs = P->getAttr<HLSLMaxRecordsAttr>())
11468+
S.Diags.Report(P->getLocation(), diag::err_hlsl_incompatible_param_attr)
11469+
<< P->getName() << maxShared->getSpelling() << maxRecs->getSpelling()
11470+
<< P->getSourceRange();
1146511471

1146611472
return true;
1146711473
}

tools/clang/test/HLSL/workgraph/node_input_compatibility.hlsl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,9 @@ void node17(ThreadNodeInputRecord<RECORD> input,
113113
NodeOutput<RECORD> output,
114114
RWThreadNodeInputRecord<RECORD> input2) // expected-error {{Node shader 'node17' may not have more than one input record}}
115115
{ }
116+
117+
[Shader("node")]
118+
[NodeLaunch("thread")]
119+
void node18(NodeOutput<RECORD> firstOut,
120+
[MaxRecords(5)][MaxRecordsSharedWith(firstOut)] NodeOutput<RECORD> secondOut) // expected-error {{parameter 'secondOut' may not have both 'maxrecordssharedwith' and 'MaxRecords'}}
121+
{ }

tools/clang/test/HLSLFileCheck/hlsl/workgraph/case092_maxoutputrecords_maxoutputrecordssharedwith.hlsl

Lines changed: 0 additions & 28 deletions
This file was deleted.

tools/clang/test/HLSLFileCheck/shader_targets/nodes/max_output_records_duplicate1.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
// Duplicate MaxRecords info with matching limits
44

55

6-
// CHECK: 28:68: error: Only one of MaxRecords or MaxRecordsSharedWith may be specified to the same parameter.
7-
// CHECK: 29:68: error: Only one of MaxRecords or MaxRecordsSharedWith may be specified to the same parameter.
8-
// CHECK: 30:68: error: Only one of MaxRecords or MaxRecordsSharedWith may be specified to the same parameter.
9-
// CHECK: 31:68: error: Only one of MaxRecords or MaxRecordsSharedWith may be specified to the same parameter.
6+
// CHECK: 28:68: error: parameter 'Output2' may not have both 'maxrecordssharedwith' and 'MaxRecords'
7+
// CHECK: 29:68: error: parameter 'Output3' may not have both 'maxrecordssharedwith' and 'MaxRecords'
8+
// CHECK: 30:68: error: parameter 'Output4' may not have both 'maxrecordssharedwith' and 'MaxRecords'
9+
// CHECK: 31:68: error: parameter 'Output5' may not have both 'maxrecordssharedwith' and 'MaxRecords'
1010

1111
struct rec0
1212
{

tools/clang/test/HLSLFileCheck/shader_targets/nodes/max_output_records_duplicate2.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
// Duplicate MaxRecords info with mismatching limits
44

5-
// CHECK: 27:68: error: Only one of MaxRecords or MaxRecordsSharedWith may be specified to the same parameter.
6-
// CHECK: 28:68: error: Only one of MaxRecords or MaxRecordsSharedWith may be specified to the same parameter.
7-
// CHECK: 29:68: error: Only one of MaxRecords or MaxRecordsSharedWith may be specified to the same parameter.
8-
// CHECK: 30:68: error: Only one of MaxRecords or MaxRecordsSharedWith may be specified to the same parameter.
5+
// CHECK: 27:68: error: parameter 'Output2' may not have both 'maxrecordssharedwith' and 'MaxRecords'
6+
// CHECK: 28:68: error: parameter 'Output3' may not have both 'maxrecordssharedwith' and 'MaxRecords'
7+
// CHECK: 29:68: error: parameter 'Output4' may not have both 'maxrecordssharedwith' and 'MaxRecords'
8+
// CHECK: 30:68: error: parameter 'Output5' may not have both 'maxrecordssharedwith' and 'MaxRecords'
99

1010
struct rec0
1111
{

0 commit comments

Comments
 (0)