Print both type in diagnostic emitted on mismatch between def/use of SSA Values ...
authorMehdi Amini <aminim@google.com>
Tue, 25 Jun 2019 00:51:44 +0000 (17:51 -0700)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Tue, 25 Jun 2019 16:05:02 +0000 (09:05 -0700)
The error would look like:

  path/filename.mlir:32:23: error: use of value '%28' expects different type than prior uses: ''i32'' vs ''!_tf.control''

PiperOrigin-RevId: 254874859

mlir/lib/Parser/Parser.cpp
mlir/test/IR/invalid.mlir

index e274012..deec877 100644 (file)
@@ -2638,7 +2638,9 @@ Value *OperationParser::resolveSSAUse(SSAUseInfo useInfo, Type type) {
       return result;
 
     emitError(useInfo.loc, "use of value '")
-        .append(useInfo.name, "' expects different type than prior uses")
+        .append(useInfo.name,
+                "' expects different type than prior uses: ", type, " vs ",
+                result->getType())
         .attachNote(getEncodedSourceLocation(entries[useInfo.number].second))
         .append("prior use here");
     return nullptr;
index 770f2da..66ba6c5 100644 (file)
@@ -366,7 +366,7 @@ func @vectors(vector<1 x vector<1xi32>>, vector<2x4xf32>)
 func @condbr_notbool() {
 ^bb0:
   %a = "foo"() : () -> i32 // expected-note {{prior use here}}
-  cond_br %a, ^bb0, ^bb0 // expected-error {{use of value '%a' expects different type than prior uses}}
+  cond_br %a, ^bb0, ^bb0 // expected-error {{use of value '%a' expects different type than prior uses: 'i1' vs 'i32'}}
 // expected-error@-1 {{expected condition type was boolean (i1)}}
 }