1// RUN: mlir-opt -split-input-file -allow-unregistered-dialect -verify-diagnostics %s
2
3ml_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
9}
10
11// -----
12ml_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
15}
16
17// -----
18ml_program.func @return_type_match(%arg0 : i64) -> i32 {
19  // expected-error @+1 {{doesn't match function result}}
20  ml_program.return %arg0 : i64
21}
22
23// -----
24ml_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
27}
28
29// -----
30ml_program.subgraph @output_type_match(%arg0 : i64) -> i32 {
31  // expected-error @+1 {{doesn't match function result}}
32  ml_program.output %arg0 : i64
33}
34
35// -----
36// expected-error @+1 {{immutable global must have an initial value}}
37ml_program.global private @const : i32
38
39// -----
40ml_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
44}
45
46// -----
47ml_program.global private mutable @var : i32
48ml_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
52}
53
54// -----
55ml_program.global private @var(42 : i64) : i64
56ml_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
60}
61