1 ; RUN: llc -mtriple=aarch64-apple-ios -asm-verbose=false \
2 ; RUN: -aarch64-enable-collect-loh=false -aarch64-enable-global-merge \
3 ; RUN: -global-merge-group-by-use -global-merge-ignore-single-use=false %s \
4 ; RUN: -o - | FileCheck %s
6 ; We assume that globals of the same size aren't reordered inside a set.
8 ; Check that we create two MergedGlobal instances for two functions using
9 ; disjoint sets of globals
11 @m1 = internal global i32 0, align 4
12 @n1 = internal global i32 0, align 4
15 define void @f1(i32 %a1, i32 %a2) #0 {
16 ; CHECK-NEXT: adrp x8, [[SET1:__MergedGlobals.[0-9]*]]@PAGE
17 ; CHECK-NEXT: add x8, x8, [[SET1]]@PAGEOFF
18 ; CHECK-NEXT: stp w0, w1, [x8]
20 store i32 %a1, i32* @m1, align 4
21 store i32 %a2, i32* @n1, align 4
25 @m2 = internal global i32 0, align 4
26 @n2 = internal global i32 0, align 4
27 @o2 = internal global i32 0, align 4
30 define void @f2(i32 %a1, i32 %a2, i32 %a3) #0 {
31 ; CHECK-NEXT: adrp x8, [[SET2:__MergedGlobals.[0-9]*]]@PAGE
32 ; CHECK-NEXT: add x8, x8, [[SET2]]@PAGEOFF
33 ; CHECK-NEXT: stp w0, w1, [x8]
34 ; CHECK-NEXT: str w2, [x8, #8]
36 store i32 %a1, i32* @m2, align 4
37 store i32 %a2, i32* @n2, align 4
38 store i32 %a3, i32* @o2, align 4
42 ; Sanity-check (don't worry about cost models) that we pick the biggest subset
43 ; of all global used "together" directly or indirectly. Here, that means
44 ; merging n3, m4, and n4 together, but ignoring m3.
46 @m3 = internal global i32 0, align 4
47 @n3 = internal global i32 0, align 4
50 define void @f3(i32 %a1, i32 %a2) #0 {
51 ; CHECK-NEXT: adrp x8, _m3@PAGE
52 ; CHECK-NEXT: adrp x9, [[SET3:__MergedGlobals[0-9]*]]@PAGE
53 ; CHECK-NEXT: str w0, [x8, _m3@PAGEOFF]
54 ; CHECK-NEXT: str w1, [x9, [[SET3]]@PAGEOFF]
56 store i32 %a1, i32* @m3, align 4
57 store i32 %a2, i32* @n3, align 4
61 @m4 = internal global i32 0, align 4
62 @n4 = internal global i32 0, align 4
65 define void @f4(i32 %a1, i32 %a2, i32 %a3) #0 {
66 ; CHECK-NEXT: adrp x8, [[SET3]]@PAGE
67 ; CHECK-NEXT: add x8, x8, [[SET3]]@PAGEOFF
68 ; CHECK-NEXT: stp w2, w0, [x8]
69 ; CHECK-NEXT: str w1, [x8, #8]
71 store i32 %a1, i32* @m4, align 4
72 store i32 %a2, i32* @n4, align 4
73 store i32 %a3, i32* @n3, align 4
77 ; Finally, check that we don't do anything with one-element global sets.
78 @o5 = internal global i32 0, align 4
81 define void @f5(i32 %a1) #0 {
82 ; CHECK-NEXT: adrp x8, _o5@PAGE
83 ; CHECK-NEXT: str w0, [x8, _o5@PAGEOFF]
85 store i32 %a1, i32* @o5, align 4
89 ; CHECK-DAG: .zerofill __DATA,__bss,_o5,4,2
91 ; CHECK-DAG: .zerofill __DATA,__bss,[[SET1]],8,2
92 ; CHECK-DAG: .zerofill __DATA,__bss,[[SET2]],12,2
93 ; CHECK-DAG: .zerofill __DATA,__bss,[[SET3]],12,2
95 attributes #0 = { nounwind }