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