[mlir] std.call reference function return types in failure

Makes it easier to see type mismatch from failure locally.

Differential Revision: https://reviews.llvm.org/D107288
This commit is contained in:
Jacques Pienaar 2021-08-05 19:51:48 -07:00
parent 7138f1cd13
commit 9d10be70a8
2 changed files with 22 additions and 2 deletions

View File

@ -622,8 +622,12 @@ LogicalResult CallOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
return emitOpError("incorrect number of results for callee");
for (unsigned i = 0, e = fnType.getNumResults(); i != e; ++i)
if (getResult(i).getType() != fnType.getResult(i))
return emitOpError("result type mismatch");
if (getResult(i).getType() != fnType.getResult(i)) {
auto diag = emitOpError("result type mismatch at index ") << i;
diag.attachNote() << " op result types: " << getResultTypes();
diag.attachNote() << "function result types: " << fnType.getResults();
return diag;
}
return success();
}

View File

@ -69,3 +69,19 @@ func @complex_constant_two_different_element_types() {
%0 = constant [1.0 : f32, -1.0 : f64] : complex<f64>
return
}
// -----
func @return_i32_f32() -> (i32, f32) {
%0 = constant 1 : i32
%1 = constant 1. : f32
return %0, %1 : i32, f32
}
func @call() {
// expected-error @+3 {{op result type mismatch at index 0}}
// expected-note @+2 {{op result types: 'f32', 'i32'}}
// expected-note @+1 {{function result types: 'i32', 'f32'}}
%0:2 = call @return_i32_f32() : () -> (f32, i32)
return
}