1 // RUN: mlir-opt -split-input-file -allow-unregistered-dialect -verify-diagnostics %s
3 ml_program.func @ssa_enforced(%arg0 : i32) -> i32 {
4 // expected-error @+1 {{does not dominate this use}}
5 %1 = "unregistered.dummy"(%0) : (i32) -> i32
6 // expected-note @+1 {{operand defined here}}
7 %0 = "unregistered.dummy"(%arg0) : (i32) -> i32
8 ml_program.return %0 : i32
12 ml_program.func @return_arity_match(%arg0 : i32) -> i32 {
13 // expected-error @+1 {{enclosing function (@return_arity_match) returns 1}}
14 ml_program.return %arg0, %arg0 : i32, i32
18 ml_program.func @return_type_match(%arg0 : i64) -> i32 {
19 // expected-error @+1 {{doesn't match function result}}
20 ml_program.return %arg0 : i64
24 ml_program.subgraph @output_arity_match(%arg0 : i32) -> i32 {
25 // expected-error @+1 {{enclosing function (@output_arity_match) outputs 1}}
26 ml_program.output %arg0, %arg0 : i32, i32
30 ml_program.subgraph @output_type_match(%arg0 : i64) -> i32 {
31 // expected-error @+1 {{doesn't match function result}}
32 ml_program.output %arg0 : i64
36 // expected-error @+1 {{immutable global must have an initial value}}
37 ml_program.global private @const : i32
40 ml_program.func @undef_global() -> i32 {
41 // expected-error @+1 {{undefined global: @nothere}}
42 %0 = ml_program.global_load_const @nothere : i32
43 ml_program.return %0 : i32
47 ml_program.global private mutable @var : i32
48 ml_program.func @mutable_const_load() -> i32 {
49 // expected-error @+1 {{op cannot load as const from mutable global @var}}
50 %0 = ml_program.global_load_const @var : i32
51 ml_program.return %0 : i32
55 ml_program.global private @var(42 : i64) : i64
56 ml_program.func @const_load_type_mismatch() -> i32 {
57 // expected-error @+1 {{cannot load from global typed 'i64' as 'i32'}}
58 %0 = ml_program.global_load_const @var : i32
59 ml_program.return %0 : i32
63 ml_program.func @load_undef() -> i32 {
64 // expected-error @+1 {{undefined global: @nothere}}
65 %0 = ml_program.global_load @nothere : i32
66 ml_program.return %0 : i32
70 ml_program.global private mutable @var(42 : i64) : i64
71 ml_program.func @load_type_mismatch() -> i32 {
72 // expected-error @+1 {{cannot load from global typed 'i64' as 'i32'}}
73 %0 = ml_program.global_load @var : i32
74 ml_program.return %0 : i32
78 ml_program.func @store_undef(%arg0: i32) {
79 // expected-error @+1 {{undefined global: @nothere}}
80 ml_program.global_store @nothere = %arg0 : i32
85 ml_program.global private mutable @var(42 : i64) : i64
86 ml_program.func @store_type_mismatch(%arg0: i32) {
87 // expected-error @+1 {{cannot store to a global typed 'i64' from 'i32'}}
88 ml_program.global_store @var = %arg0 : i32
93 ml_program.global private @var(42 : i64) : i64
94 ml_program.func @store_immutable(%arg0: i64) {
95 // expected-error @+1 {{cannot store to an immutable global @var}}
96 ml_program.global_store @var = %arg0 : i64
102 ml_program.global private mutable @global_mutable_undef : tensor<?xi32>
103 ml_program.subgraph @global_load_store_tokens() -> (tensor<?xi32>, !ml_program.token) {
104 %token1 = ml_program.token
105 %0, %token2 = ml_program.global_load_graph @global_mutable_undef
106 ordering(() -> !ml_program.token) : tensor<?xi32>
107 %token3 = ml_program.global_store_graph @global_mutable_undef = %0
108 // expected-error @+1 {{expected '->'}}
109 ordering(%token1, %token2) : tensor<?xi32>
111 ml_program.output %0, %token3 : tensor<?xi32>, !ml_program.token