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 5 6 ; We assume that globals of the same size aren't reordered inside a set. 7 8 ; Check that we create two MergedGlobal instances for two functions using 9 ; disjoint sets of globals 10 11 @m1 = internal global i32 0, align 4 12 @n1 = internal global i32 0, align 4 13 14 ; CHECK-LABEL: f1: 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] 19 ; CHECK-NEXT: ret 20 store i32 %a1, i32* @m1, align 4 21 store i32 %a2, i32* @n1, align 4 22 ret void 23 } 24 25 @m2 = internal global i32 0, align 4 26 @n2 = internal global i32 0, align 4 27 @o2 = internal global i32 0, align 4 28 29 ; CHECK-LABEL: f2: 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] 35 ; CHECK-NEXT: ret 36 store i32 %a1, i32* @m2, align 4 37 store i32 %a2, i32* @n2, align 4 38 store i32 %a3, i32* @o2, align 4 39 ret void 40 } 41 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. 45 46 @m3 = internal global i32 0, align 4 47 @n3 = internal global i32 0, align 4 48 49 ; CHECK-LABEL: f3: 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] 55 ; CHECK-NEXT: ret 56 store i32 %a1, i32* @m3, align 4 57 store i32 %a2, i32* @n3, align 4 58 ret void 59 } 60 61 @m4 = internal global i32 0, align 4 62 @n4 = internal global i32 0, align 4 63 64 ; CHECK-LABEL: f4: 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] 70 ; CHECK-NEXT: ret 71 store i32 %a1, i32* @m4, align 4 72 store i32 %a2, i32* @n4, align 4 73 store i32 %a3, i32* @n3, align 4 74 ret void 75 } 76 77 ; Finally, check that we don't do anything with one-element global sets. 78 @o5 = internal global i32 0, align 4 79 80 ; CHECK-LABEL: f5: 81 define void @f5(i32 %a1) #0 { 82 ; CHECK-NEXT: adrp x8, _o5@PAGE 83 ; CHECK-NEXT: str w0, [x8, _o5@PAGEOFF] 84 ; CHECK-NEXT: ret 85 store i32 %a1, i32* @o5, align 4 86 ret void 87 } 88 89 ; CHECK-DAG: .zerofill __DATA,__bss,_o5,4,2 90 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 94 95 attributes #0 = { nounwind } 96