1 // RUN: mlir-opt -allow-unregistered-dialect %s -test-symbol-uses -split-input-file -verify-diagnostics
3 // Symbol references to the module itself don't affect uses of symbols within
5 // expected-remark@below {{symbol_removable function successfully erased}}
6 module attributes {sym.outside_use = @symbol_foo } {
7 // expected-remark@+1 {{symbol has 3 uses}}
8 func.func private @symbol_foo()
10 // expected-remark@below {{symbol has no uses}}
11 // expected-remark@below {{found use of symbol : @symbol_foo}}
12 // expected-remark@below {{symbol contains 3 nested references}}
13 func.func @symbol_bar() attributes {sym.use = @symbol_foo} {
14 // expected-remark@+1 {{found use of symbol : @symbol_foo}}
17 use = [{nested_symbol = [@symbol_foo]}],
18 z_other_non_symbol_attr
20 // expected-remark@+1 {{found use of symbol : @symbol_foo}}
21 "foo.op"() { use = distinct[0]<@symbol_foo> } : () -> ()
24 // expected-remark@below {{symbol has no uses}}
25 func.func private @symbol_removable()
27 // expected-remark@+1 {{symbol has 1 use}}
28 func.func private @symbol_baz()
30 // expected-remark@+1 {{found use of symbol : @symbol_baz}}
31 module attributes {test.reference = @symbol_baz} {
32 "foo.op"() {test.nested_reference = @symbol_baz} : () -> ()
38 // Test nested attribute support
40 // expected-remark@+1 {{symbol has 2 uses}}
42 // expected-remark@+1 {{symbol has 1 uses}}
44 // expected-remark@+1 {{symbol has 1 uses}}
45 func.func nested @foo()
49 // expected-remark@below {{symbol has no uses}}
50 // expected-remark@below {{symbol contains 2 nested references}}
51 func.func @symbol_bar() {
52 // expected-remark@below {{found use of symbol : @module_b::@module_c::@foo : "foo"}}
53 // expected-remark@below {{found use of symbol : @module_b::@module_c::@foo : "module_c"}}
54 // expected-remark@below {{found use of symbol : @module_b::@module_c::@foo : "module_b"}}
55 // expected-remark@below {{found use of symbol : @module_b : "module_b"}}
57 use_1 = [{ nested_symbol = [@module_b::@module_c::@foo]}],
66 // expected-remark@+1 {{contains an unknown nested operation that 'may' define a new symbol table}}
67 func.func @symbol_bar() {
68 "foo.possibly_unknown_symbol_table"() ({