1// RUN: mlir-opt -allow-unregistered-dialect %s -test-symbol-rauw -split-input-file | FileCheck %s 2 3// Symbol references to the module itself don't affect uses of symbols within 4// its table. 5// CHECK: module 6// CHECK-SAME: @symbol_foo 7module attributes {sym.outside_use = @symbol_foo } { 8 // CHECK: func private @replaced_foo 9 func private @symbol_foo() attributes {sym.new_name = "replaced_foo" } 10 11 // CHECK: func @symbol_bar 12 // CHECK: @replaced_foo 13 func @symbol_bar() attributes {sym.use = @symbol_foo} { 14 // CHECK: foo.op 15 // CHECK-SAME: non_symbol_attr, 16 // CHECK-SAME: use = [{nested_symbol = [@replaced_foo], other_use = @symbol_bar, z_use = @replaced_foo}], 17 // CHECK-SAME: z_non_symbol_attr_3 18 "foo.op"() { 19 non_symbol_attr, 20 use = [{nested_symbol = [@symbol_foo], other_use = @symbol_bar, z_use = @symbol_foo}], 21 z_non_symbol_attr_3 22 } : () -> () 23 } 24 25 // CHECK: module attributes {test.reference = @replaced_foo} 26 module attributes {test.reference = @symbol_foo} { 27 // CHECK: foo.op 28 // CHECK-SAME: @symbol_foo 29 "foo.op"() {test.nested_reference = @symbol_foo} : () -> () 30 } 31} 32 33// ----- 34 35// Check the support for nested references. 36 37// CHECK: module 38module { 39 // CHECK: module @module_a 40 module @module_a { 41 // CHECK: func nested @replaced_foo 42 func nested @foo() attributes {sym.new_name = "replaced_foo" } 43 } 44 45 // CHECK: module @replaced_module_b 46 module @module_b attributes {sym.new_name = "replaced_module_b"} { 47 // CHECK: module @replaced_module_c 48 module @module_c attributes {sym.new_name = "replaced_module_c"} { 49 // CHECK: func nested @replaced_foo 50 func nested @foo() attributes {sym.new_name = "replaced_foo" } 51 } 52 } 53 54 // CHECK: func @symbol_bar 55 func @symbol_bar() { 56 // CHECK: foo.op 57 // CHECK-SAME: use_1 = @module_a::@replaced_foo 58 // CHECK-SAME: use_2 = @replaced_module_b::@replaced_module_c::@replaced_foo 59 "foo.op"() { 60 use_1 = @module_a::@foo, 61 use_2 = @module_b::@module_c::@foo 62 } : () -> () 63 } 64} 65 66// ----- 67 68// Check that the replacement fails for potentially unknown symbol tables. 69module { 70 // CHECK: func private @failed_repl 71 func private @failed_repl() attributes {sym.new_name = "replaced_name" } 72 73 "foo.possibly_unknown_symbol_table"() ({ 74 }) : () -> () 75} 76