From 34d12c15f7d8336c74bd4493e8d284dc169587b9 Mon Sep 17 00:00:00 2001 From: Stephen Neuendorffer Date: Thu, 30 Jul 2020 14:47:42 -0700 Subject: [PATCH] [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 --- mlir/lib/Dialect/StandardOps/IR/Ops.cpp | 4 +++- mlir/test/IR/operand.mlir | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp index 37d8d73..0960096 100644 --- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp @@ -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"); diff --git a/mlir/test/IR/operand.mlir b/mlir/test/IR/operand.mlir index 3ca8832..7daa90d 100644 --- a/mlir/test/IR/operand.mlir +++ b/mlir/test/IR/operand.mlir @@ -33,3 +33,15 @@ func @error_in_second_variadic_operand(%arg0: tensor, %arg1: f32) { "test.mixed_normal_variadic_operand"(%arg0, %arg0, %arg0, %arg1, %arg0) : (tensor, tensor, tensor, f32, tensor) -> () 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 +} -- 2.7.4