2018-09-20 12:35:11 +08:00
|
|
|
// RUN: mlir-opt %s -split-input-file -verify
|
2018-06-25 00:10:36 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// Check different error cases.
|
|
|
|
// -----
|
2018-06-25 02:18:29 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
extfunc @illegaltype(i) // expected-error {{expected type}}
|
2018-06-25 02:18:29 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// -----
|
2018-06-25 23:10:46 +08:00
|
|
|
|
2018-11-10 13:24:37 +08:00
|
|
|
mlfunc @illegaltype() {
|
|
|
|
%0 = constant splat<<vector 4 x f32>, 0> : vector<4 x f32> // expected-error {{expected type}}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
Eliminate "primitive" types from being a thing, splitting them into FloatType
and OtherType. Other type is now the thing that holds AffineInt, Control,
eventually Resource, Variant, String, etc. FloatType holds the floating point
types, and allows convenient query of isa<FloatType>().
This fixes issues where we allowed control to be the element type of tensor,
memref, vector. At the same time, ban AffineInt from being an element of a
vector/memref/tensor as well since we don't need it.
I updated the spec to match this as well.
PiperOrigin-RevId: 206361942
2018-07-28 04:09:58 +08:00
|
|
|
extfunc @nestedtensor(tensor<tensor<i8>>) -> () // expected-error {{invalid tensor element type}}
|
2018-06-25 02:18:29 +08:00
|
|
|
|
2018-07-17 00:45:22 +08:00
|
|
|
// -----
|
|
|
|
// Test no map in memref type.
|
2018-07-26 03:55:50 +08:00
|
|
|
extfunc @memrefs(memref<2x4xi8, >) // expected-error {{expected list element}}
|
2018-07-17 00:45:22 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
// Test non-existent map in memref type.
|
2018-07-26 03:55:50 +08:00
|
|
|
extfunc @memrefs(memref<2x4xi8, #map7>) // expected-error {{undefined affine map id 'map7'}}
|
2018-07-17 00:45:22 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
// Test non hash identifier in memref type.
|
2018-07-26 03:55:50 +08:00
|
|
|
extfunc @memrefs(memref<2x4xi8, %map7>) // expected-error {{expected '(' at start of dimensional identifiers list}}
|
2018-07-17 00:45:22 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
// Test non-existent map in map composition of memref type.
|
|
|
|
#map0 = (d0, d1) -> (d0, d1)
|
|
|
|
|
2018-07-26 03:55:50 +08:00
|
|
|
extfunc @memrefs(memref<2x4xi8, #map0, #map8>) // expected-error {{undefined affine map id 'map8'}}
|
2018-07-17 00:45:22 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
// Test multiple memory space error.
|
|
|
|
#map0 = (d0, d1) -> (d0, d1)
|
2018-07-26 03:55:50 +08:00
|
|
|
extfunc @memrefs(memref<2x4xi8, #map0, 1, 2>) // expected-error {{multiple memory spaces specified in memref type}}
|
2018-07-17 00:45:22 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
// Test affine map after memory space.
|
|
|
|
#map0 = (d0, d1) -> (d0, d1)
|
|
|
|
#map1 = (d0, d1) -> (d0, d1)
|
|
|
|
|
2018-07-26 03:55:50 +08:00
|
|
|
extfunc @memrefs(memref<2x4xi8, #map0, 1, #map1>) // expected-error {{affine map after memory space in memref type}}
|
2018-07-17 00:45:22 +08:00
|
|
|
|
2018-10-26 21:15:38 +08:00
|
|
|
// -----
|
|
|
|
// Test dimension mismatch between memref and layout map.
|
|
|
|
// The error must be emitted even for the trivial identity layout maps that are
|
|
|
|
// dropped in type creation.
|
|
|
|
#map0 = (d0, d1) -> (d0, d1)
|
2018-11-02 16:48:22 +08:00
|
|
|
extfunc @memrefs(memref<42xi8, #map0>) // expected-error {{memref affine map dimension mismatch}}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
#map0 = (d0, d1) -> (d0, d1)
|
|
|
|
#map1 = (d0) -> (d0)
|
|
|
|
extfunc @memrefs(memref<42x42xi8, #map0, #map1>) // expected-error {{memref affine map dimension mismatch}}
|
2018-10-26 21:15:38 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// -----
|
2018-06-25 23:10:46 +08:00
|
|
|
|
2018-09-19 07:36:26 +08:00
|
|
|
extfunc @illegalattrs() -> () attributes { key } // expected-error {{expected ':' in attribute list}}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-06-25 00:10:36 +08:00
|
|
|
cfgfunc @foo()
|
2018-07-15 14:06:24 +08:00
|
|
|
cfgfunc @bar() // expected-error {{expected '{' in CFG function}}
|
2018-06-25 02:18:29 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// -----
|
2018-06-25 23:10:46 +08:00
|
|
|
|
2018-10-07 08:21:53 +08:00
|
|
|
extfunc missingsigil() -> (i1, index, f32) // expected-error {{expected a function identifier like}}
|
2018-06-25 02:18:29 +08:00
|
|
|
|
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// -----
|
2018-06-25 02:18:29 +08:00
|
|
|
|
|
|
|
cfgfunc @bad_branch() {
|
2018-10-14 22:55:29 +08:00
|
|
|
bb12:
|
|
|
|
br missing // expected-error {{reference to an undefined basic block}}
|
2018-06-25 02:18:29 +08:00
|
|
|
}
|
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// -----
|
2018-06-25 02:18:29 +08:00
|
|
|
|
|
|
|
cfgfunc @block_redef() {
|
|
|
|
bb42:
|
|
|
|
return
|
2018-07-15 14:06:24 +08:00
|
|
|
bb42: // expected-error {{redefinition of block 'bb42'}}
|
2018-06-25 23:10:46 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// -----
|
2018-06-25 23:10:46 +08:00
|
|
|
|
|
|
|
cfgfunc @no_terminator() {
|
|
|
|
bb40:
|
|
|
|
return
|
|
|
|
bb41:
|
2018-07-26 02:15:20 +08:00
|
|
|
bb42: // expected-error {{custom op 'bb42' is unknown}}
|
2018-06-25 02:18:29 +08:00
|
|
|
return
|
|
|
|
}
|
2018-06-29 08:02:32 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// -----
|
2018-06-29 08:02:32 +08:00
|
|
|
|
2018-07-23 06:45:24 +08:00
|
|
|
cfgfunc @block_no_rparen() {
|
|
|
|
bb42 (%bb42 : i32: // expected-error {{expected ')' to end argument list}}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
cfgfunc @block_arg_no_ssaid() {
|
|
|
|
bb42 (i32): // expected-error {{expected SSA operand}}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
cfgfunc @block_arg_no_type() {
|
|
|
|
bb42 (%0): // expected-error {{expected ':' and type for SSA operand}}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-10-14 22:55:29 +08:00
|
|
|
cfgfunc @block_arg_no_close_paren() {
|
|
|
|
bb42:
|
|
|
|
br bb2( // expected-error@+1 {{expected ')' to close argument list}}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-10-23 23:12:59 +08:00
|
|
|
cfgfunc @block_first_has_predecessor() {
|
|
|
|
// expected-error@-1 {{first block of cfgfunc must not have predecessors}}
|
|
|
|
bb42:
|
|
|
|
br bb43
|
|
|
|
bb43:
|
|
|
|
br bb42
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-09-19 07:36:26 +08:00
|
|
|
cfgfunc @illegalattrs() -> ()
|
|
|
|
attributes { key } { // expected-error {{expected ':' in attribute list}}
|
|
|
|
bb42:
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-06-29 08:02:32 +08:00
|
|
|
mlfunc @foo()
|
2018-08-10 03:28:58 +08:00
|
|
|
mlfunc @bar() // expected-error {{expected '{' before statement list}}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-09-08 00:08:13 +08:00
|
|
|
mlfunc @empty() { // expected-error {{ML function must end with return statement}}
|
2018-08-10 03:28:58 +08:00
|
|
|
}
|
2018-06-29 08:02:32 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// -----
|
2018-06-29 08:02:32 +08:00
|
|
|
|
2018-09-19 07:36:26 +08:00
|
|
|
mlfunc @illegalattrs() -> ()
|
|
|
|
attributes { key } { // expected-error {{expected ':' in attribute list}}
|
|
|
|
bb42:
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-09-08 00:08:13 +08:00
|
|
|
mlfunc @no_return() { // expected-error {{ML function must end with return statement}}
|
2018-08-10 03:28:58 +08:00
|
|
|
"foo"() : () -> ()
|
|
|
|
}
|
2018-06-29 11:45:33 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// -----
|
2018-06-29 11:45:33 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
" // expected-error {{expected}}
|
2018-06-29 11:45:33 +08:00
|
|
|
"
|
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// -----
|
2018-06-29 11:45:33 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
" // expected-error {{expected}}
|
2018-06-29 11:45:33 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// -----
|
2018-06-29 11:45:33 +08:00
|
|
|
|
2018-07-19 06:31:25 +08:00
|
|
|
cfgfunc @bad_op_type() {
|
|
|
|
bb40:
|
|
|
|
"foo"() : i32 // expected-error {{expected function type}}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// -----
|
|
|
|
|
2018-06-29 11:45:33 +08:00
|
|
|
cfgfunc @no_terminator() {
|
|
|
|
bb40:
|
2018-07-19 06:31:25 +08:00
|
|
|
"foo"() : ()->()
|
|
|
|
""() : ()->() // expected-error {{empty operation name is invalid}}
|
2018-06-29 11:45:33 +08:00
|
|
|
return
|
|
|
|
}
|
2018-06-30 13:08:05 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// -----
|
2018-06-30 13:08:05 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
extfunc @illegaltype(i0) // expected-error {{invalid integer width}}
|
2018-06-30 13:08:05 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// -----
|
2018-07-04 08:51:28 +08:00
|
|
|
|
2018-08-10 03:28:58 +08:00
|
|
|
mlfunc @malformed_for_percent() {
|
|
|
|
for i = 1 to 10 { // expected-error {{expected SSA identifier for the loop variable}}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
mlfunc @malformed_for_equal() {
|
|
|
|
for %i 1 to 10 { // expected-error {{expected '='}}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
mlfunc @malformed_for_to() {
|
2018-07-20 00:52:39 +08:00
|
|
|
for %i = 1 too 10 { // expected-error {{expected 'to' between bounds}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-07-04 08:51:28 +08:00
|
|
|
mlfunc @incomplete_for() {
|
2018-07-20 00:52:39 +08:00
|
|
|
for %i = 1 to 10 step 2
|
2018-07-15 14:06:24 +08:00
|
|
|
} // expected-error {{expected '{' before statement list}}
|
2018-06-30 13:08:05 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// -----
|
2018-07-04 08:51:28 +08:00
|
|
|
|
2018-07-20 00:52:39 +08:00
|
|
|
mlfunc @nonconstant_step(%1 : i32) {
|
2018-08-25 14:38:14 +08:00
|
|
|
for %2 = 1 to 5 step %1 { // expected-error {{expected integer}}
|
2018-07-20 00:52:39 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-09-28 09:03:27 +08:00
|
|
|
mlfunc @for_negative_stride() {
|
|
|
|
for %i = 1 to 10 step -1
|
|
|
|
} // expected-error {{step has to be a positive integer}}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-07-04 08:51:28 +08:00
|
|
|
mlfunc @non_statement() {
|
2018-07-26 02:15:20 +08:00
|
|
|
asd // expected-error {{custom op 'asd' is unknown}}
|
2018-07-04 08:51:28 +08:00
|
|
|
}
|
2018-07-05 11:45:39 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// -----
|
2018-07-05 11:45:39 +08:00
|
|
|
|
2018-08-08 05:24:38 +08:00
|
|
|
mlfunc @invalid_if_conditional1() {
|
|
|
|
for %i = 1 to 10 {
|
2018-08-29 06:26:20 +08:00
|
|
|
if () { // expected-error {{expected ':' or '['}}
|
2018-08-08 05:24:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
mlfunc @invalid_if_conditional2() {
|
|
|
|
for %i = 1 to 10 {
|
2018-08-29 06:26:20 +08:00
|
|
|
if (i)[N] : (i >= ) // expected-error {{expected '== 0' or '>= 0' at end of affine constraint}}
|
2018-08-08 05:24:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
mlfunc @invalid_if_conditional3() {
|
|
|
|
for %i = 1 to 10 {
|
2018-08-29 06:26:20 +08:00
|
|
|
if (i)[N] : (i == 1) // expected-error {{expected '0' after '=='}}
|
2018-08-08 05:24:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
mlfunc @invalid_if_conditional4() {
|
|
|
|
for %i = 1 to 10 {
|
2018-08-29 06:26:20 +08:00
|
|
|
if (i)[N] : (i >= 2) // expected-error {{expected '0' after '>='}}
|
2018-08-08 05:24:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
mlfunc @invalid_if_conditional5() {
|
|
|
|
for %i = 1 to 10 {
|
2018-08-29 06:26:20 +08:00
|
|
|
if (i)[N] : (i <= 0 ) // expected-error {{expected '== 0' or '>= 0' at end of affine constraint}}
|
2018-08-08 05:24:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
mlfunc @invalid_if_conditional6() {
|
|
|
|
for %i = 1 to 10 {
|
2018-08-29 06:26:20 +08:00
|
|
|
if (i) : (i) // expected-error {{expected '== 0' or '>= 0' at end of affine constraint}}
|
2018-08-08 05:24:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
// TODO (support if (1)?
|
|
|
|
mlfunc @invalid_if_conditional7() {
|
|
|
|
for %i = 1 to 10 {
|
2018-08-29 06:26:20 +08:00
|
|
|
if (i) : (1) // expected-error {{expected '== 0' or '>= 0' at end of affine constraint}}
|
2018-08-08 05:24:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
#map = (d0) -> (% // expected-error {{invalid SSA name}}
|
2018-07-12 04:26:23 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// -----
|
2018-07-19 23:35:28 +08:00
|
|
|
|
|
|
|
cfgfunc @test() {
|
|
|
|
bb40:
|
2018-07-21 00:28:54 +08:00
|
|
|
%1 = "foo"() : (i32)->i64 // expected-error {{expected 0 operand types but had 1}}
|
2018-07-19 23:35:28 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
cfgfunc @redef() {
|
|
|
|
bb42:
|
2018-07-24 23:34:58 +08:00
|
|
|
%x = "xxx"(){index: 0} : ()->i32 // expected-error {{previously defined here}}
|
|
|
|
%x = "xxx"(){index: 0} : ()->i32 // expected-error {{redefinition of SSA value '%x'}}
|
2018-07-19 23:35:28 +08:00
|
|
|
return
|
2018-07-20 00:52:39 +08:00
|
|
|
}
|
|
|
|
|
2018-07-21 09:41:34 +08:00
|
|
|
// -----
|
|
|
|
|
|
|
|
cfgfunc @undef() {
|
|
|
|
bb42:
|
|
|
|
%x = "xxx"(%y) : (i32)->i32 // expected-error {{use of undeclared SSA value}}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-07-20 00:52:39 +08:00
|
|
|
mlfunc @missing_rbrace() {
|
2018-08-10 03:28:58 +08:00
|
|
|
return
|
|
|
|
mlfunc @d() {return} // expected-error {{expected '}' after statement list}}
|
2018-07-20 00:52:39 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
mlfunc @malformed_type(%a : intt) { // expected-error {{expected type}}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-08-21 23:42:19 +08:00
|
|
|
cfgfunc @resulterror() -> i32 {
|
2018-07-22 05:32:09 +08:00
|
|
|
bb42:
|
2018-11-16 04:32:21 +08:00
|
|
|
return // expected-error {{'return' op has 0 operands, but enclosing function returns 1}}
|
2018-07-22 05:32:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2018-07-23 06:45:24 +08:00
|
|
|
|
2018-09-07 11:56:12 +08:00
|
|
|
mlfunc @mlfunc_resulterror() -> i32 {
|
2018-10-23 23:46:26 +08:00
|
|
|
return // expected-error {{'return' op has 0 operands, but enclosing function returns 1}}
|
2018-08-10 03:28:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
cfgfunc @argError() {
|
2018-07-23 06:45:24 +08:00
|
|
|
bb1(%a: i64): // expected-error {{previously defined here}}
|
|
|
|
br bb2
|
|
|
|
bb2(%a: i64): // expected-error{{redefinition of SSA value '%a'}}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-09-08 00:08:13 +08:00
|
|
|
cfgfunc @bbargMismatch(i32, f32) { // expected-error {{first block of cfgfunc must have 2 arguments to match function signature}}
|
2018-07-23 06:45:24 +08:00
|
|
|
bb42(%0: f32):
|
|
|
|
return
|
|
|
|
}
|
2018-07-23 23:42:19 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-09-07 11:56:12 +08:00
|
|
|
cfgfunc @br_mismatch() {
|
2018-07-24 02:48:22 +08:00
|
|
|
bb0:
|
2018-07-23 23:42:19 +08:00
|
|
|
%0 = "foo"() : () -> (i1, i17)
|
2018-09-07 11:56:12 +08:00
|
|
|
// expected-error @+1 {{branch has 2 operands, but target block has 1}}
|
2018-07-25 06:01:27 +08:00
|
|
|
br bb1(%0#1, %0#0 : i17, i1)
|
2018-07-23 23:42:19 +08:00
|
|
|
|
|
|
|
bb1(%x: i17):
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-07-24 02:48:22 +08:00
|
|
|
// -----
|
|
|
|
|
|
|
|
// Test no nested vector.
|
|
|
|
extfunc @vectors(vector<1 x vector<1xi32>>, vector<2x4xf32>)
|
2018-11-09 05:41:21 +08:00
|
|
|
// expected-error@-1 {{vector elements must be primitives}}
|
Eliminate "primitive" types from being a thing, splitting them into FloatType
and OtherType. Other type is now the thing that holds AffineInt, Control,
eventually Resource, Variant, String, etc. FloatType holds the floating point
types, and allows convenient query of isa<FloatType>().
This fixes issues where we allowed control to be the element type of tensor,
memref, vector. At the same time, ban AffineInt from being an element of a
vector/memref/tensor as well since we don't need it.
I updated the spec to match this as well.
PiperOrigin-RevId: 206361942
2018-07-28 04:09:58 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-07-25 06:01:27 +08:00
|
|
|
cfgfunc @condbr_notbool() {
|
|
|
|
bb0:
|
|
|
|
%a = "foo"() : () -> i32 // expected-error {{prior use here}}
|
|
|
|
cond_br %a, bb0, bb0 // expected-error {{use of value '%a' expects different type than prior uses}}
|
2018-11-16 04:32:21 +08:00
|
|
|
// expected-error@-1 {{expected condition type was boolean (i1)}}
|
2018-07-25 06:01:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
cfgfunc @condbr_badtype() {
|
|
|
|
bb0:
|
|
|
|
%c = "foo"() : () -> i1
|
|
|
|
%a = "foo"() : () -> i32
|
|
|
|
cond_br %c, bb0(%a, %a : i32, bb0) // expected-error {{expected type}}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
cfgfunc @condbr_a_bb_is_not_a_type() {
|
|
|
|
bb0:
|
|
|
|
%c = "foo"() : () -> i1
|
|
|
|
%a = "foo"() : () -> i32
|
|
|
|
cond_br %c, bb0(%a, %a : i32, i32), i32 // expected-error {{expected basic block name}}
|
|
|
|
}
|
2018-07-27 09:09:20 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-10-14 22:55:29 +08:00
|
|
|
cfgfunc @undef() {
|
|
|
|
bb0:
|
|
|
|
%x = "xxx"(%y) : (i32)->i32 // expected-error {{use of undeclared SSA value name}}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-07-27 09:09:20 +08:00
|
|
|
mlfunc @undef() {
|
|
|
|
%x = "xxx"(%y) : (i32)->i32 // expected-error {{use of undefined SSA value %y}}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-07-31 06:18:10 +08:00
|
|
|
// -----
|
|
|
|
|
|
|
|
mlfunc @duplicate_induction_var() {
|
|
|
|
for %i = 1 to 10 { // expected-error {{previously defined here}}
|
2018-08-01 14:14:16 +08:00
|
|
|
for %i = 1 to 10 { // expected-error {{redefinition of SSA value '%i'}}
|
2018-07-31 06:18:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
2018-08-06 12:12:29 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-08-21 23:42:19 +08:00
|
|
|
mlfunc @dominance_failure() {
|
2018-08-06 12:12:29 +08:00
|
|
|
for %i = 1 to 10 {
|
|
|
|
}
|
2018-10-07 08:21:53 +08:00
|
|
|
"xxx"(%i) : (index)->() // expected-error {{operand #0 does not dominate this use}}
|
2018-08-06 12:12:29 +08:00
|
|
|
return
|
|
|
|
}
|
2018-08-10 03:28:58 +08:00
|
|
|
|
2018-09-22 05:40:36 +08:00
|
|
|
// -----
|
|
|
|
|
|
|
|
cfgfunc @dominance_failure() {
|
|
|
|
bb0:
|
|
|
|
"foo"(%x) : (i32) -> () // expected-error {{operand #0 does not dominate this use}}
|
|
|
|
br bb1
|
|
|
|
bb1:
|
2018-09-27 22:43:44 +08:00
|
|
|
%x = "bar"() : () -> i32 // expected-note {{operand defined here}}
|
2018-09-22 05:40:36 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-08-10 03:28:58 +08:00
|
|
|
// -----
|
|
|
|
|
|
|
|
mlfunc @return_type_mismatch() -> i32 {
|
|
|
|
%0 = "foo"() : ()->f32
|
2018-09-07 11:56:12 +08:00
|
|
|
return %0 : f32 // expected-error {{type of return operand 0 doesn't match function result type}}
|
2018-08-10 03:28:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
mlfunc @return_inside_loop() -> i8 {
|
|
|
|
for %i = 1 to 100 {
|
|
|
|
%a = "foo"() : ()->i8
|
|
|
|
return %a : i8
|
|
|
|
// expected-error@-1 {{'return' op must be the last statement in the ML function}}
|
|
|
|
}
|
|
|
|
}
|
2018-08-18 07:49:42 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
extfunc @redef()
|
|
|
|
extfunc @redef() // expected-error {{redefinition of function named 'redef'}}
|
2018-08-20 12:17:22 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
cfgfunc @foo() {
|
|
|
|
bb0:
|
|
|
|
%x = constant @foo : (i32) -> () // expected-error {{reference to function with mismatched type}}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-08-22 08:55:22 +08:00
|
|
|
cfgfunc @undefined_function() {
|
2018-08-20 12:17:22 +08:00
|
|
|
bb0:
|
|
|
|
%x = constant @bar : (i32) -> () // expected-error {{reference to undefined function 'bar'}}
|
|
|
|
return
|
|
|
|
}
|
2018-08-25 14:38:14 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
#map1 = (i)[j] -> (i+j)
|
|
|
|
|
2018-10-07 08:21:53 +08:00
|
|
|
mlfunc @bound_symbol_mismatch(%N : index) {
|
2018-08-25 14:38:14 +08:00
|
|
|
for %i = #map1(%N) to 100 {
|
|
|
|
// expected-error@-1 {{symbol operand count and affine map symbol count must match}}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
#map1 = (i)[j] -> (i+j)
|
|
|
|
|
2018-10-07 08:21:53 +08:00
|
|
|
mlfunc @bound_dim_mismatch(%N : index) {
|
2018-08-25 14:38:14 +08:00
|
|
|
for %i = #map1(%N, %N)[%N] to 100 {
|
|
|
|
// expected-error@-1 {{dim operand count and affine map dim count must match}}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
#map1 = (i)[j] -> (i+j)
|
|
|
|
|
2018-10-07 08:21:53 +08:00
|
|
|
mlfunc @invalid_dim_nested(%N : index) {
|
2018-08-25 14:38:14 +08:00
|
|
|
for %i = 1 to 100 {
|
2018-10-07 08:21:53 +08:00
|
|
|
%a = "foo"(%N) : (index)->(index)
|
2018-08-25 14:38:14 +08:00
|
|
|
for %j = 1 to #map1(%a)[%i] {
|
2018-08-29 06:26:20 +08:00
|
|
|
// expected-error@-1 {{value '%a' cannot be used as a dimension id}}
|
2018-08-25 14:38:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
#map1 = (i)[j] -> (i+j)
|
|
|
|
|
2018-10-07 08:21:53 +08:00
|
|
|
mlfunc @invalid_dim_affine_apply(%N : index) {
|
2018-08-25 14:38:14 +08:00
|
|
|
for %i = 1 to 100 {
|
2018-10-07 08:21:53 +08:00
|
|
|
%a = "foo"(%N) : (index)->(index)
|
2018-08-25 14:38:14 +08:00
|
|
|
%w = affine_apply (i)->(i+1) (%a)
|
|
|
|
for %j = 1 to #map1(%w)[%i] {
|
2018-08-29 06:26:20 +08:00
|
|
|
// expected-error@-1 {{value '%w' cannot be used as a dimension id}}
|
2018-08-25 14:38:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
#map1 = (i)[j] -> (i+j)
|
|
|
|
|
2018-10-07 08:21:53 +08:00
|
|
|
mlfunc @invalid_symbol_iv(%N : index) {
|
2018-08-25 14:38:14 +08:00
|
|
|
for %i = 1 to 100 {
|
2018-10-07 08:21:53 +08:00
|
|
|
%a = "foo"(%N) : (index)->(index)
|
2018-08-25 14:38:14 +08:00
|
|
|
for %j = 1 to #map1(%N)[%i] {
|
2018-08-29 06:26:20 +08:00
|
|
|
// expected-error@-1 {{value '%i' cannot be used as a symbol}}
|
2018-08-25 14:38:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
#map1 = (i)[j] -> (i+j)
|
|
|
|
|
2018-10-07 08:21:53 +08:00
|
|
|
mlfunc @invalid_symbol_nested(%N : index) {
|
2018-08-25 14:38:14 +08:00
|
|
|
for %i = 1 to 100 {
|
2018-10-07 08:21:53 +08:00
|
|
|
%a = "foo"(%N) : (index)->(index)
|
2018-08-25 14:38:14 +08:00
|
|
|
for %j = 1 to #map1(%N)[%a] {
|
2018-08-29 06:26:20 +08:00
|
|
|
// expected-error@-1 {{value '%a' cannot be used as a symbol}}
|
2018-08-25 14:38:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
#map1 = (i)[j] -> (i+j)
|
|
|
|
|
2018-10-07 08:21:53 +08:00
|
|
|
mlfunc @invalid_symbol_affine_apply(%N : index) {
|
2018-08-25 14:38:14 +08:00
|
|
|
for %i = 1 to 100 {
|
|
|
|
%w = affine_apply (i)->(i+1) (%i)
|
|
|
|
for %j = 1 to #map1(%i)[%w] {
|
2018-08-29 06:26:20 +08:00
|
|
|
// expected-error@-1 {{value '%w' cannot be used as a symbol}}
|
2018-08-25 14:38:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
mlfunc @large_bound() {
|
|
|
|
for %i = 1 to 9223372036854775810 {
|
2018-10-07 08:21:53 +08:00
|
|
|
// expected-error@-1 {{bound or step is too large for index}}
|
2018-08-25 14:38:14 +08:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2018-10-07 08:21:53 +08:00
|
|
|
mlfunc @max_in_upper_bound(%N : index) {
|
2018-08-25 14:38:14 +08:00
|
|
|
for %i = 1 to max (i)->(N, 100) { //expected-error {{expected SSA operand}}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
mlfunc @step_typo() {
|
|
|
|
for %i = 1 to 100 step -- 1 { //expected-error {{expected integer}}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
mlfunc @invalid_bound_map(%N : i32) {
|
|
|
|
for %i = 1 to (i)->(j)(%N) { //expected-error {{use of undeclared identifier}}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
2018-08-29 06:26:20 +08:00
|
|
|
|
|
|
|
// -----
|
2018-10-26 09:33:42 +08:00
|
|
|
#set0 = (i)[N] : (i >= 0, N - i >= 0)
|
2018-08-29 06:26:20 +08:00
|
|
|
|
2018-10-07 08:21:53 +08:00
|
|
|
mlfunc @invalid_if_operands1(%N : index) {
|
2018-08-29 06:26:20 +08:00
|
|
|
for %i = 1 to 10 {
|
2018-10-26 09:33:42 +08:00
|
|
|
if #set0(%i) {
|
2018-08-29 06:26:20 +08:00
|
|
|
// expected-error@-1 {{symbol operand count and integer set symbol count must match}}
|
|
|
|
|
|
|
|
// -----
|
2018-10-26 09:33:42 +08:00
|
|
|
#set0 = (i)[N] : (i >= 0, N - i >= 0)
|
2018-08-29 06:26:20 +08:00
|
|
|
|
2018-10-07 08:21:53 +08:00
|
|
|
mlfunc @invalid_if_operands2(%N : index) {
|
2018-08-29 06:26:20 +08:00
|
|
|
for %i = 1 to 10 {
|
2018-10-26 09:33:42 +08:00
|
|
|
if #set0()[%N] {
|
2018-08-29 06:26:20 +08:00
|
|
|
// expected-error@-1 {{dim operand count and integer set dim count must match}}
|
|
|
|
|
|
|
|
// -----
|
2018-10-26 09:33:42 +08:00
|
|
|
#set0 = (i)[N] : (i >= 0, N - i >= 0)
|
2018-08-29 06:26:20 +08:00
|
|
|
|
2018-10-07 08:21:53 +08:00
|
|
|
mlfunc @invalid_if_operands3(%N : index) {
|
2018-08-29 06:26:20 +08:00
|
|
|
for %i = 1 to 10 {
|
2018-10-26 09:33:42 +08:00
|
|
|
if #set0(%i)[%i] {
|
2018-08-29 06:26:20 +08:00
|
|
|
// expected-error@-1 {{value '%i' cannot be used as a symbol}}
|
|
|
|
|
2018-10-10 05:40:41 +08:00
|
|
|
// -----
|
|
|
|
// expected-error@+1 {{expected '"' in string literal}}
|
|
|
|
"J// -----
|
|
|
|
mlfunc @calls(%arg0 : i32) {
|
|
|
|
// expected-error@+1 {{expected type}}
|
|
|
|
%z = "casdasda"(%x) : (ppop32) -> i32
|
|
|
|
}
|
2018-10-14 22:55:29 +08:00
|
|
|
// -----
|
|
|
|
// expected-error@+2 {{expected SSA operand}}
|
|
|
|
cfgfunc@n(){b(
|
|
|
|
// -----
|
2018-10-19 04:54:44 +08:00
|
|
|
|
|
|
|
cfgfunc @elementsattr_non_tensor_type() -> () {
|
|
|
|
bb0:
|
|
|
|
"foo"(){bar: dense<i32, [4]>} : () -> () // expected-error {{expected elements literal has a tensor or vector type}}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
cfgfunc @elementsattr_non_ranked() -> () {
|
|
|
|
bb0:
|
|
|
|
"foo"(){bar: dense<tensor<?xi32>, [4]>} : () -> () // expected-error {{tensor literals must be ranked and have static shape}}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
cfgfunc @elementsattr_shape_mismatch() -> () {
|
|
|
|
bb0:
|
|
|
|
"foo"(){bar: dense<tensor<5xi32>, [4]>} : () -> () // expected-error {{inferred shape of elements literal ([1]) does not match type ([5])}}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
cfgfunc @elementsattr_invalid() -> () {
|
|
|
|
bb0:
|
|
|
|
"foo"(){bar: dense<tensor<2xi32>, [4, [5]]>} : () -> () // expected-error {{tensor literal is invalid; ranks are not consistent between elements}}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
cfgfunc @elementsattr_badtoken() -> () {
|
|
|
|
bb0:
|
|
|
|
"foo"(){bar: dense<tensor<1xi32>, [tf_opaque]>} : () -> () // expected-error {{expected '[' or scalar constant inside tensor literal}}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
cfgfunc @elementsattr_floattype1() -> () {
|
|
|
|
bb0:
|
|
|
|
"foo"(){bar: dense<tensor<1xi32>, [4.0]>} : () -> () // expected-error {{expected tensor literal element has integer type}}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
cfgfunc @elementsattr_floattype2() -> () {
|
|
|
|
bb0:
|
|
|
|
"foo"(){bar: dense<tensor<1xf32>, [4]>} : () -> () // expected-error {{expected tensor literal element has float type}}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
cfgfunc @elementsattr_toolarge1() -> () {
|
|
|
|
bb0:
|
|
|
|
"foo"(){bar: dense<tensor<1xi8>, [777]>} : () -> () // expected-error {{tensor literal element has more bits than that specified in the type}}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
cfgfunc @elementsattr_toolarge2() -> () {
|
|
|
|
bb0:
|
|
|
|
"foo"(){bar: dense<tensor<1xi8>, [-777]>} : () -> () // expected-error {{tensor literal element has more bits than that specified in the type}}
|
|
|
|
}
|
2018-10-24 04:44:04 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
cfgfunc @elementsattr_malformed_opaque() -> () {
|
|
|
|
bb0:
|
|
|
|
"foo"(){bar: opaque<tensor<1xi8>, "0xQZz123">} : () -> () // expected-error {{opaque string only contains hex digits}}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
cfgfunc @elementsattr_malformed_opaque1() -> () {
|
|
|
|
bb0:
|
|
|
|
"foo"(){bar: opaque<tensor<1xi8>, "00abc">} : () -> () // expected-error {{opaque string should start with '0x'}}
|
2018-10-26 09:33:42 +08:00
|
|
|
}
|