[Mlir-commits] [mlir] 34d12c1 - [MLIR] Better message for FuncOp type mismatch

Stephen Neuendorffer llvmlistbot at llvm.org
Fri Oct 2 09:31:59 PDT 2020


Author: Stephen Neuendorffer
Date: 2020-10-02T09:31:44-07:00
New Revision: 34d12c15f7d8336c74bd4493e8d284dc169587b9

URL: https://github.com/llvm/llvm-project/commit/34d12c15f7d8336c74bd4493e8d284dc169587b9
DIFF: https://github.com/llvm/llvm-project/commit/34d12c15f7d8336c74bd4493e8d284dc169587b9.diff

LOG: [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

Added: 
    

Modified: 
    mlir/lib/Dialect/StandardOps/IR/Ops.cpp
    mlir/test/IR/operand.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
index 37d8d73e3dc9..09600963be0e 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 3ca8832821c3..7daa90dcc694 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<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
+}


        


More information about the Mlir-commits mailing list