[MLIR] Better message for FuncOp type mismatch

Previously the actual types were not shown, which makes the message
difficult to grok in the context of long lowering chains.  Also, it
appears that there were no actual tests for this.

Differential Revision: https://reviews.llvm.org/D88318
This commit is contained in:
Stephen Neuendorffer 2020-07-30 14:47:42 -07:00
parent 33fa3dbce9
commit 34d12c15f7
2 changed files with 15 additions and 1 deletions

View File

@ -758,7 +758,9 @@ static LogicalResult verify(CallOp op) {
for (unsigned i = 0, e = fnType.getNumInputs(); i != e; ++i)
if (op.getOperand(i).getType() != fnType.getInput(i))
return op.emitOpError("operand type mismatch");
return op.emitOpError("operand type mismatch: expected operand type ")
<< fnType.getInput(i) << ", but provided "
<< op.getOperand(i).getType() << " for operand number " << i;
if (fnType.getNumResults() != op.getNumResults())
return op.emitOpError("incorrect number of results for callee");

View File

@ -33,3 +33,15 @@ func @error_in_second_variadic_operand(%arg0: tensor<f32>, %arg1: f32) {
"test.mixed_normal_variadic_operand"(%arg0, %arg0, %arg0, %arg1, %arg0) : (tensor<f32>, tensor<f32>, tensor<f32>, f32, tensor<f32>) -> ()
return
}
// -----
func @testfunc(%arg0: i32) {
return
}
func @invalid_call_operandtype() {
%0 = constant 0.0 : f32
// expected-error @+1 {{operand type mismatch: expected operand type 'i32', but provided 'f32' for operand number 0}}
call @testfunc(%0) : (f32) -> ()
return
}