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