Skip to content

Commit be35264

Browse files
committed
Wordsmith RegionBranchOpInterface verification errors
I was having a lot of trouble parsing the messages. In particular, the messages like: ``` <stdin>:3:8: error: 'scf.if' op along control flow edge from Region #0 to scf.if source #1 type '!npcomprt.tensor' should match input #1 type 'tensor<?xindex>' ``` In particular, one thing that kept catching me was parsing the "to scf.if source #1 type" as one thing, but really it is "to parent results: source type #1". Differential Revision: https://reviews.llvm.org/D87334
1 parent 0ab6a15 commit be35264

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

mlir/lib/Interfaces/ControlFlowInterfaces.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -103,24 +103,23 @@ static LogicalResult verifyTypesAlongAllEdges(
103103
if (sourceNo)
104104
diag << "Region #" << sourceNo.getValue();
105105
else
106-
diag << op->getName();
106+
diag << "parent operands";
107107

108108
diag << " to ";
109109
if (succRegionNo)
110110
diag << "Region #" << succRegionNo.getValue();
111111
else
112-
diag << op->getName();
112+
diag << "parent results";
113113
return diag;
114114
};
115115

116116
TypeRange sourceTypes = getInputsTypesForRegion(succRegionNo);
117117
TypeRange succInputsTypes = succ.getSuccessorInputs().getTypes();
118118
if (sourceTypes.size() != succInputsTypes.size()) {
119119
InFlightDiagnostic diag = op->emitOpError(" region control flow edge ");
120-
return printEdgeName(diag)
121-
<< " has " << sourceTypes.size()
122-
<< " source operands, but target successor needs "
123-
<< succInputsTypes.size();
120+
return printEdgeName(diag) << ": source has " << sourceTypes.size()
121+
<< " operands, but target successor needs "
122+
<< succInputsTypes.size();
124123
}
125124

126125
for (auto typesIdx :
@@ -130,8 +129,8 @@ static LogicalResult verifyTypesAlongAllEdges(
130129
if (sourceType != inputType) {
131130
InFlightDiagnostic diag = op->emitOpError(" along control flow edge ");
132131
return printEdgeName(diag)
133-
<< " source #" << typesIdx.index() << " type " << sourceType
134-
<< " should match input #" << typesIdx.index() << " type "
132+
<< ": source type #" << typesIdx.index() << " " << sourceType
133+
<< " should match input type #" << typesIdx.index() << " "
135134
<< inputType;
136135
}
137136
}

mlir/test/Dialect/SCF/invalid.mlir

+2-2
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ func @reduceReturn_not_inside_reduce(%arg0 : f32) {
325325

326326
func @std_if_incorrect_yield(%arg0: i1, %arg1: f32)
327327
{
328-
// expected-error@+1 {{region control flow edge from Region #0 to scf.if has 1 source operands, but target successor needs 2}}
328+
// expected-error@+1 {{region control flow edge from Region #0 to parent results: source has 1 operands, but target successor needs 2}}
329329
%x, %y = scf.if %arg0 -> (f32, f32) {
330330
%0 = addf %arg1, %arg1 : f32
331331
scf.yield %0 : f32
@@ -401,7 +401,7 @@ func @std_for_operands_mismatch_3(%arg0 : index, %arg1 : index, %arg2 : index) {
401401
func @std_for_operands_mismatch_4(%arg0 : index, %arg1 : index, %arg2 : index) {
402402
%s0 = constant 0.0 : f32
403403
%t0 = constant 1.0 : f32
404-
// expected-error @+1 {{along control flow edge from Region #0 to Region #0 source #1 type 'i32' should match input #1 type 'f32'}}
404+
// expected-error @+1 {{along control flow edge from Region #0 to Region #0: source type #1 'i32' should match input type #1 'f32'}}
405405
%result1:2 = scf.for %i0 = %arg0 to %arg1 step %arg2
406406
iter_args(%si = %s0, %ti = %t0) -> (f32, f32) {
407407
%sn = addf %si, %si : f32

0 commit comments

Comments
 (0)