88// This ensures our fix doesn't break the existing multi-module functionality
99// while fixing the single-module case.
1010
11+ // Check that all the structors are present
12+ // CHECK-DAG: llvm.func internal @_GLOBAL__sub_I_mod1()
13+ // CHECK-DAG: llvm.func internal @_GLOBAL__sub_I_mod2()
14+ // CHECK-DAG: llvm.func internal @_GLOBAL__sub_D_mod2()
15+
16+ // Check global_{c,d}tors ops have correct lists
17+ // CHECK-DAG: llvm.mlir.global_ctors ctors = [@_GLOBAL__sub_I_mod1, @_GLOBAL__sub_I_mod2], priorities = [65535 : i32, 65534 : i32], data = [#llvm.zero, #llvm.zero]
18+ // CHECK-DAG: llvm.mlir.global_dtors dtors = [@_GLOBAL__sub_D_mod2], priorities = [65535 : i32], data = [#llvm.zero]
19+
20+ // Check regular functions
21+ // CHECK-DAG: llvm.func @func_mod1
22+ // CHECK-DAG: llvm.func @func_mod2
23+
1124module @first_module {
1225 // Constructor function in first module
13- // CHECK-LABEL: llvm.func internal @_GLOBAL__sub_I_mod1()
1426 llvm.func internal @_GLOBAL__sub_I_mod1 () {
1527 %c100 = llvm.mlir.constant (100 : i32 ) : i32
1628 llvm.return
1729 }
1830
1931 // Global constructor table for first module
20- // CHECK: llvm.mlir.global_ctors ctors = [@_GLOBAL__sub_I_mod1], priorities = [65535 : i32], data = [#llvm.zero]
2132 llvm.mlir.global_ctors ctors = [@_GLOBAL__sub_I_mod1 ], priorities = [65535 : i32 ], data = [#llvm.zero ]
2233
2334 // Regular function
24- // CHECK-LABEL: llvm.func @func_mod1()
2535 llvm.func @func_mod1 () {
2636 llvm.return
2737 }
@@ -30,31 +40,26 @@ module @first_module {
3040// -----
3141
3242module @second_module {
33- // Constructor function in second module
34- // CHECK-LABEL: llvm.func internal @_GLOBAL__sub_I_mod2()
43+ // Constructor function in second module
3544 llvm.func internal @_GLOBAL__sub_I_mod2 () {
3645 %c200 = llvm.mlir.constant (200 : i32 ) : i32
3746 llvm.return
3847 }
3948
4049 // Destructor function for variety
41- // CHECK-LABEL: llvm.func internal @_GLOBAL__sub_D_mod2()
4250 llvm.func internal @_GLOBAL__sub_D_mod2 () {
4351 %c0 = llvm.mlir.constant (0 : i32 ) : i32
4452 llvm.return
4553 }
4654
4755 // Global constructor and destructor tables for second module
4856 // These should be properly merged with the first module's constructors
49- // CHECK: llvm.mlir.global_ctors ctors = [@_GLOBAL__sub_I_mod2], priorities = [65534 : i32], data = [#llvm.zero]
5057 llvm.mlir.global_ctors ctors = [@_GLOBAL__sub_I_mod2 ], priorities = [65534 : i32 ], data = [#llvm.zero ]
51-
52- // CHECK: llvm.mlir.global_dtors dtors = [@_GLOBAL__sub_D_mod2], priorities = [65535 : i32], data = [#llvm.zero]
58+
5359 llvm.mlir.global_dtors dtors = [@_GLOBAL__sub_D_mod2 ], priorities = [65535 : i32 ], data = [#llvm.zero ]
5460
5561 // Regular function
56- // CHECK-LABEL: llvm.func @func_mod2()
5762 llvm.func @func_mod2 () {
5863 llvm.return
5964 }
60- }
65+ }
0 commit comments