156 lines · plain
1// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics2 3func.func @affine_apply_no_map() {4^bb0:5 %i = arith.constant 0 : index6 %x = "affine.apply" (%i) { } : (index) -> (index) // expected-error {{requires attribute 'map'}}7 return8}9 10// -----11 12func.func @affine_apply_wrong_operand_count() {13^bb0:14 %i = arith.constant 0 : index15 %x = "affine.apply" (%i) {map = affine_map<(d0, d1) -> ((d0 + 1), (d1 + 2))>} : (index) -> (index) // expected-error {{'affine.apply' op operand count and affine map dimension and symbol count must match}}16 return17}18 19// -----20 21func.func @affine_apply_wrong_result_count() {22^bb0:23 %i = arith.constant 0 : index24 %j = arith.constant 1 : index25 %x = "affine.apply" (%i, %j) {map = affine_map<(d0, d1) -> ((d0 + 1), (d1 + 2))>} : (index,index) -> (index) // expected-error {{'affine.apply' op mapping must produce one value}}26 return27}28 29// -----30 31func.func @unknown_custom_op() {32^bb0:33 %i = test.crazyThing() {value = 0} : () -> index // expected-error {{custom op 'test.crazyThing' is unknown}}34 return35}36 37// -----38 39func.func @unknown_std_op() {40 // expected-error@+1 {{unregistered operation 'func.foo_bar_op' found in dialect ('func') that does not allow unknown operations}}41 %0 = "func.foo_bar_op"() : () -> index42 return43}44 45// -----46 47func.func @calls(%arg0: i32) {48 %x = call @calls() : () -> i32 // expected-error {{incorrect number of operands for callee}}49 return50}51 52// -----53 54func.func @func_with_ops(i32, i32, i32) {55^bb0(%cond : i32, %t : i32, %f : i32):56 // expected-error@+2 {{different type than prior uses}}57 // expected-note@-2 {{prior use here}}58 %r = arith.select %cond, %t, %f : i3259}60 61// -----62 63func.func @func_with_ops(i32, i32, i32) {64^bb0(%cond : i32, %t : i32, %f : i32):65 // expected-error@+1 {{op operand #0 must be bool-like}}66 %r = "arith.select"(%cond, %t, %f) : (i32, i32, i32) -> i3267}68 69// -----70 71func.func @func_with_ops(i1, i32, i64) {72^bb0(%cond : i1, %t : i32, %f : i64):73 // TODO: expand post change in verification order. This is currently only74 // verifying that the type verification is failing but not the specific error75 // message. In final state the error should refer to mismatch in true_value and76 // false_value.77 // expected-error@+1 {{type}}78 %r = "arith.select"(%cond, %t, %f) : (i1, i32, i64) -> i3279}80 81// -----82 83func.func @func_with_ops(vector<12xi1>, vector<42xi32>, vector<42xi32>) {84^bb0(%cond : vector<12xi1>, %t : vector<42xi32>, %f : vector<42xi32>):85 // expected-error@+1 {{'arith.select' op failed to verify that condition is signless i1 or has matching shape}}86 %r = "arith.select"(%cond, %t, %f) : (vector<12xi1>, vector<42xi32>, vector<42xi32>) -> vector<42xi32>87}88 89// -----90 91func.func @func_with_ops(tensor<12xi1>, tensor<42xi32>, tensor<42xi32>) {92^bb0(%cond : tensor<12xi1>, %t : tensor<42xi32>, %f : tensor<42xi32>):93 // expected-error@+1 {{'arith.select' op failed to verify that condition is signless i1 or has matching shape}}94 %r = "arith.select"(%cond, %t, %f) : (tensor<12xi1>, tensor<42xi32>, tensor<42xi32>) -> tensor<42xi32>95}96 97// -----98 99func.func @return_not_in_function() {100 "foo.region"() ({101 // expected-error@+1 {{'func.return' op expects parent op 'func.func'}}102 return103 }): () -> ()104 return105}106 107// -----108 109func.func @invalid_splat(%v : f32) { // expected-note {{prior use here}}110 vector.broadcast %v : f64 to vector<8xf64>111 // expected-error@-1 {{expects different type than prior uses}}112 return113}114 115// -----116 117// Case that resulted in leak previously.118 119// expected-error@+1 {{expected ':' after block name}}120"g"()({^a:^b })121 122// -----123 124// expected-error@+1 {{number of operands and types do not match: got 0 operands and 1 types}}125test.variadic_args_types_split "hello_world" : i32126 127// -----128 129// Test multiple verifier errors in the same split to ensure all are reported.130 131func.func @verify_fail_1() {132 // expected-error@+1 {{'arith.constant' op integer return type must be signless}}133 %r = "arith.constant"() {value = -1 : si32} : () -> si32134 return135}136 137func.func @verify_fail_2() {138 // expected-error@+1 {{'arith.constant' op value must be an integer, float, or elements attribute}}139 %r = "arith.constant"() {value = "hi" : i32} : () -> i32140 return141}142 143func.func @verify_fail_3() {144 // expected-error@+1 {{'arith.constant' op integer return type must be signless}}145 %r = "arith.constant"() {value = -3 : si32} : () -> si32146 return147}148 149// -----150 151// Verify that symbols with results are rejected152module {153 // expected-error@+1 {{'test.symbol_with_result' op symbols must not have results}}154 %0 = "test.symbol_with_result"() <{sym_name = "test_symbol"}> : () -> i32155}156