1 ; RUN: llc -mtriple=aarch64-apple-ios -asm-verbose=false \
2 ; RUN: -aarch64-enable-collect-loh=false -O1 -global-merge-group-by-use \
3 ; RUN: -global-merge-ignore-single-use %s -o - | FileCheck %s
5 ; Check that, at -O1, we only merge globals used in minsize functions.
6 ; We assume that globals of the same size aren't reordered inside a set.
7 ; We use -global-merge-ignore-single-use, and thus only expect one merged set.
9 @m1 = internal global i32 0, align 4
10 @n1 = internal global i32 0, align 4
13 define void @f1(i32 %a1, i32 %a2) minsize nounwind {
14 ; CHECK-NEXT: adrp x8, [[SET:__MergedGlobals]]@PAGE
15 ; CHECK-NEXT: add x8, x8, [[SET]]@PAGEOFF
16 ; CHECK-NEXT: stp w0, w1, [x8]
18 store i32 %a1, i32* @m1, align 4
19 store i32 %a2, i32* @n1, align 4
23 @m2 = internal global i32 0, align 4
24 @n2 = internal global i32 0, align 4
27 define void @f2(i32 %a1, i32 %a2) nounwind {
28 ; CHECK-NEXT: adrp x8, _m2@PAGE
29 ; CHECK-NEXT: adrp x9, _n2@PAGE
30 ; CHECK-NEXT: str w0, [x8, _m2@PAGEOFF]
31 ; CHECK-NEXT: str w1, [x9, _n2@PAGEOFF]
33 store i32 %a1, i32* @m2, align 4
34 store i32 %a2, i32* @n2, align 4
38 ; If we have use sets partially overlapping between a minsize and a non-minsize
39 ; function, explicitly check that we only consider the globals used in the
40 ; minsize function for merging.
42 @m3 = internal global i32 0, align 4
43 @n3 = internal global i32 0, align 4
46 define void @f3(i32 %a1, i32 %a2) minsize nounwind {
47 ; CHECK-NEXT: adrp x8, [[SET]]@PAGE+8
48 ; CHECK-NEXT: add x8, x8, [[SET]]@PAGEOFF+8
49 ; CHECK-NEXT: stp w0, w1, [x8]
51 store i32 %a1, i32* @m3, align 4
52 store i32 %a2, i32* @n3, align 4
56 @n4 = internal global i32 0, align 4
59 define void @f4(i32 %a1, i32 %a2) nounwind {
60 ; CHECK-NEXT: adrp x8, [[SET]]@PAGE+8
61 ; CHECK-NEXT: adrp x9, _n4@PAGE
62 ; CHECK-NEXT: str w0, [x8, [[SET]]@PAGEOFF+8]
63 ; CHECK-NEXT: str w1, [x9, _n4@PAGEOFF]
65 store i32 %a1, i32* @m3, align 4
66 store i32 %a2, i32* @n4, align 4
70 ; CHECK-DAG: .zerofill __DATA,__bss,[[SET]],16,2
71 ; CHECK-DAG: .zerofill __DATA,__bss,_m2,4,2
72 ; CHECK-DAG: .zerofill __DATA,__bss,_n2,4,2
73 ; CHECK-DAG: .zerofill __DATA,__bss,_n4,4,2