1; RUN: llc -mtriple=aarch64-apple-ios -asm-verbose=false -aarch64-collect-loh=false \ 2; RUN: -O1 -global-merge-group-by-use -global-merge-ignore-single-use \ 3; RUN: %s -o - | FileCheck %s 4 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. 8 9@m1 = internal global i32 0, align 4 10@n1 = internal global i32 0, align 4 11 12; CHECK-LABEL: f1: 13define void @f1(i32 %a1, i32 %a2) minsize nounwind { 14; CHECK-NEXT: adrp x8, [[SET:l__MergedGlobals]]@PAGE 15; CHECK-NEXT: add x8, x8, [[SET]]@PAGEOFF 16; CHECK-NEXT: stp w0, w1, [x8] 17; CHECK-NEXT: ret 18 store i32 %a1, i32* @m1, align 4 19 store i32 %a2, i32* @n1, align 4 20 ret void 21} 22 23@m2 = internal global i32 0, align 4 24@n2 = internal global i32 0, align 4 25 26; CHECK-LABEL: f2: 27define 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] 32; CHECK-NEXT: ret 33 store i32 %a1, i32* @m2, align 4 34 store i32 %a2, i32* @n2, align 4 35 ret void 36} 37 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. 41 42@m3 = internal global i32 0, align 4 43@n3 = internal global i32 0, align 4 44 45; CHECK-LABEL: f3: 46define void @f3(i32 %a1, i32 %a2) minsize nounwind { 47; CHECK-NEXT: adrp x8, [[SET]]@PAGE 48; CHECK-NEXT: add x8, x8, [[SET]]@PAGEOFF 49; CHECK-NEXT: stp w0, w1, [x8, #8] 50; CHECK-NEXT: ret 51 store i32 %a1, i32* @m3, align 4 52 store i32 %a2, i32* @n3, align 4 53 ret void 54} 55 56@n4 = internal global i32 0, align 4 57 58; CHECK-LABEL: f4: 59define void @f4(i32 %a1, i32 %a2) nounwind { 60; CHECK-NEXT: adrp x8, [[SET]]@PAGE 61; CHECK-NEXT: add x8, x8, [[SET]]@PAGEOFF 62; CHECK-NEXT: adrp x9, _n4@PAGE 63; CHECK-NEXT: str w0, [x8, #8] 64; CHECK-NEXT: str w1, [x9, _n4@PAGEOFF] 65; CHECK-NEXT: ret 66 store i32 %a1, i32* @m3, align 4 67 store i32 %a2, i32* @n4, align 4 68 ret void 69} 70 71; CHECK-DAG: .zerofill __DATA,__bss,[[SET]],16,3 72; CHECK-DAG: .zerofill __DATA,__bss,_m2,4,2 73; CHECK-DAG: .zerofill __DATA,__bss,_n2,4,2 74; CHECK-DAG: .zerofill __DATA,__bss,_n4,4,2 75