test-symbol-uses.mlir
2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// RUN: mlir-opt -allow-unregistered-dialect %s -test-symbol-uses -split-input-file -verify-diagnostics
// Symbol references to the module itself don't affect uses of symbols within
// its table.
// expected-remark@below {{symbol_removable function successfully erased}}
module attributes {sym.outside_use = @symbol_foo } {
// expected-remark@+1 {{symbol has 2 uses}}
func @symbol_foo()
// expected-remark@below {{symbol has no uses}}
// expected-remark@below {{found use of symbol : @symbol_foo}}
// expected-remark@below {{symbol contains 2 nested references}}
func @symbol_bar() attributes {sym.use = @symbol_foo} {
// expected-remark@+1 {{found use of symbol : @symbol_foo}}
"foo.op"() {
non_symbol_attr,
use = [{ nested_symbol = [@symbol_foo]}],
z_other_non_symbol_attr
} : () -> ()
}
// expected-remark@below {{symbol has no uses}}
func @symbol_removable()
// expected-remark@+1 {{symbol has 1 use}}
func @symbol_baz()
// expected-remark@+1 {{found use of symbol : @symbol_baz}}
module attributes {test.reference = @symbol_baz} {
"foo.op"() {test.nested_reference = @symbol_baz} : () -> ()
}
}
// -----
// Test nested attribute support
module {
// expected-remark@+1 {{symbol has 2 uses}}
module @module_b {
// expected-remark@+1 {{symbol has 1 uses}}
module @module_c {
// expected-remark@+1 {{symbol has 1 uses}}
func @foo()
}
}
// expected-remark@below {{symbol has no uses}}
// expected-remark@below {{symbol contains 2 nested references}}
func @symbol_bar() {
// expected-remark@below {{found use of symbol : @module_b::@module_c::@foo : "foo"}}
// expected-remark@below {{found use of symbol : @module_b::@module_c::@foo : "module_c"}}
// expected-remark@below {{found use of symbol : @module_b::@module_c::@foo : "module_b"}}
// expected-remark@below {{found use of symbol : @module_b : "module_b"}}
"foo.op"() {
use_1 = [{ nested_symbol = [@module_b::@module_c::@foo]}],
use_2 = @module_b
} : () -> ()
}
}
// -----
// expected-remark@+1 {{contains an unknown nested operation that 'may' define a new symbol table}}
func @symbol_bar() {
"foo.possibly_unknown_symbol_table"() ({
}) : () -> ()
}