1 // RUN: mlir-opt -allow-unregistered-dialect -mlir-print-local-scope %s -test-symbol-rauw -split-input-file | FileCheck %s
3 // Symbol references to the module itself don't affect uses of symbols within
6 // CHECK-SAME: @symbol_foo
7 module attributes {sym.outside_use = @symbol_foo } {
8 // CHECK: func private @replaced_foo
9 func.func private @symbol_foo() attributes {sym.new_name = "replaced_foo" }
11 // CHECK: func @symbol_bar
12 // CHECK: @replaced_foo
13 func.func @symbol_bar() attributes {sym.use = @symbol_foo} {
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
20 use = [{nested_symbol = [@symbol_foo], other_use = @symbol_bar, z_use = @symbol_foo}],
25 // CHECK: module attributes {test.reference = @replaced_foo}
26 module attributes {test.reference = @symbol_foo} {
28 // CHECK-SAME: @symbol_foo
29 "foo.op"() {test.nested_reference = @symbol_foo} : () -> ()
35 // Check the support for nested references.
39 // CHECK: module @module_a
41 // CHECK: func nested @replaced_foo
42 func.func nested @foo() attributes {sym.new_name = "replaced_foo" }
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.func nested @foo() attributes {sym.new_name = "replaced_foo" }
54 // CHECK: func @symbol_bar
55 func.func @symbol_bar() {
57 // CHECK-SAME: use_1 = @module_a::@replaced_foo
58 // CHECK-SAME: use_2 = @replaced_module_b::@replaced_module_c::@replaced_foo
60 use_1 = @module_a::@foo,
61 use_2 = @module_b::@module_c::@foo
68 // Check that the replacement fails for potentially unknown symbol tables.
70 // CHECK: func private @failed_repl
71 func.func private @failed_repl() attributes {sym.new_name = "replaced_name" }
73 "foo.possibly_unknown_symbol_table"() ({
79 // Check that replacement works in any implementations of SubElements.
81 // CHECK: func private @replaced_foo
82 func.func private @symbol_foo() attributes {sym.new_name = "replaced_foo" }
84 // CHECK: func @symbol_bar
85 func.func @symbol_bar() {
87 // CHECK-SAME: non_symbol_attr,
88 // CHECK-SAME: use = [#test.sub_elements_access<[@replaced_foo], @symbol_bar, @replaced_foo>, distinct[0]<@replaced_foo>],
89 // CHECK-SAME: z_non_symbol_attr_3
92 use = [#test.sub_elements_access<[@symbol_foo],@symbol_bar,@symbol_foo>, distinct[0]<@symbol_foo>],
101 // CHECK: module @replaced_foo
102 module @foo attributes {sym.new_name = "replaced_foo" } {
103 // CHECK: func.func private @foo
104 func.func private @foo()
108 // CHECK-SAME: use = @replaced_foo::@foo