1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -mtriple=aarch64 -code-model=tiny -relocation-model=pic < %s | FileCheck %s --check-prefix=CHECK-PIC
3 ; RUN: llc -verify-machineinstrs -mtriple=aarch64 -code-model=tiny -relocation-model=pic -fast-isel < %s | FileCheck %s --check-prefix=CHECK-PIC
4 ; RUN: llc -verify-machineinstrs -mtriple=aarch64 -code-model=tiny -relocation-model=pic -global-isel < %s | FileCheck %s --check-prefix=CHECK-PIC-GLOBISEL
6 ; Note fast-isel tests here will fall back to isel
8 @src = external local_unnamed_addr global [65536 x i8], align 1
9 @dst = external global [65536 x i8], align 1
10 @ptr = external local_unnamed_addr global ptr, align 8
12 define dso_preemptable void @foo1() {
13 ; CHECK-PIC-LABEL: foo1:
14 ; CHECK-PIC: // %bb.0: // %entry
15 ; CHECK-PIC-NEXT: ldr x8, :got:src
16 ; CHECK-PIC-NEXT: ldrb w8, [x8]
17 ; CHECK-PIC-NEXT: ldr x9, :got:dst
18 ; CHECK-PIC-NEXT: strb w8, [x9]
21 ; CHECK-PIC-GLOBISEL-LABEL: foo1:
22 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
23 ; CHECK-PIC-GLOBISEL-NEXT: ldr x8, :got:src
24 ; CHECK-PIC-GLOBISEL-NEXT: ldrb w8, [x8]
25 ; CHECK-PIC-GLOBISEL-NEXT: ldr x9, :got:dst
26 ; CHECK-PIC-GLOBISEL-NEXT: strb w8, [x9]
27 ; CHECK-PIC-GLOBISEL-NEXT: ret
29 %0 = load i8, ptr @src, align 1
30 store i8 %0, ptr @dst, align 1
34 define dso_preemptable void @foo2() {
35 ; CHECK-PIC-LABEL: foo2:
36 ; CHECK-PIC: // %bb.0: // %entry
37 ; CHECK-PIC-NEXT: ldr x8, :got:ptr
38 ; CHECK-PIC-NEXT: ldr x9, :got:dst
39 ; CHECK-PIC-NEXT: str x9, [x8]
42 ; CHECK-PIC-GLOBISEL-LABEL: foo2:
43 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
44 ; CHECK-PIC-GLOBISEL-NEXT: ldr x8, :got:ptr
45 ; CHECK-PIC-GLOBISEL-NEXT: ldr x9, :got:dst
46 ; CHECK-PIC-GLOBISEL-NEXT: str x9, [x8]
47 ; CHECK-PIC-GLOBISEL-NEXT: ret
49 store ptr @dst, ptr @ptr, align 8
53 define dso_preemptable void @foo3() {
54 ; FIXME: Needn't adr ptr
56 ; CHECK-PIC-LABEL: foo3:
57 ; CHECK-PIC: // %bb.0: // %entry
58 ; CHECK-PIC-NEXT: ldr x8, :got:src
59 ; CHECK-PIC-NEXT: ldr x9, :got:ptr
60 ; CHECK-PIC-NEXT: ldrb w8, [x8]
61 ; CHECK-PIC-NEXT: ldr x9, [x9]
62 ; CHECK-PIC-NEXT: strb w8, [x9]
65 ; CHECK-PIC-GLOBISEL-LABEL: foo3:
66 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
67 ; CHECK-PIC-GLOBISEL-NEXT: ldr x8, :got:src
68 ; CHECK-PIC-GLOBISEL-NEXT: ldr x9, :got:ptr
69 ; CHECK-PIC-GLOBISEL-NEXT: ldrb w8, [x8]
70 ; CHECK-PIC-GLOBISEL-NEXT: ldr x9, [x9]
71 ; CHECK-PIC-GLOBISEL-NEXT: strb w8, [x9]
72 ; CHECK-PIC-GLOBISEL-NEXT: ret
74 %0 = load i8, ptr @src, align 1
75 %1 = load ptr, ptr @ptr, align 8
76 store i8 %0, ptr %1, align 1
80 @lsrc = internal global i8 0, align 4
81 @ldst = internal global i8 0, align 4
82 @lptr = internal global ptr null, align 8
84 define dso_preemptable void @bar1() {
85 ; CHECK-PIC-LABEL: bar1:
86 ; CHECK-PIC: // %bb.0: // %entry
87 ; CHECK-PIC-NEXT: adr x8, lsrc
88 ; CHECK-PIC-NEXT: adr x9, ldst
89 ; CHECK-PIC-NEXT: ldrb w8, [x8]
90 ; CHECK-PIC-NEXT: strb w8, [x9]
93 ; CHECK-PIC-GLOBISEL-LABEL: bar1:
94 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
95 ; CHECK-PIC-GLOBISEL-NEXT: adr x8, lsrc
96 ; CHECK-PIC-GLOBISEL-NEXT: adr x9, ldst
97 ; CHECK-PIC-GLOBISEL-NEXT: ldrb w8, [x8]
98 ; CHECK-PIC-GLOBISEL-NEXT: strb w8, [x9]
99 ; CHECK-PIC-GLOBISEL-NEXT: ret
101 %0 = load i8, ptr @lsrc, align 4
102 store i8 %0, ptr @ldst, align 4
106 define dso_preemptable void @bar2() {
107 ; CHECK-PIC-LABEL: bar2:
108 ; CHECK-PIC: // %bb.0: // %entry
109 ; CHECK-PIC-NEXT: adr x8, lptr
110 ; CHECK-PIC-NEXT: adr x9, ldst
111 ; CHECK-PIC-NEXT: str x9, [x8]
112 ; CHECK-PIC-NEXT: ret
114 ; CHECK-PIC-GLOBISEL-LABEL: bar2:
115 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
116 ; CHECK-PIC-GLOBISEL-NEXT: adr x8, lptr
117 ; CHECK-PIC-GLOBISEL-NEXT: adr x9, ldst
118 ; CHECK-PIC-GLOBISEL-NEXT: str x9, [x8]
119 ; CHECK-PIC-GLOBISEL-NEXT: ret
121 store ptr @ldst, ptr @lptr, align 8
125 define dso_preemptable void @bar3() {
126 ; FIXME: Needn't adr lptr
128 ; CHECK-PIC-LABEL: bar3:
129 ; CHECK-PIC: // %bb.0: // %entry
130 ; CHECK-PIC-NEXT: adr x8, lsrc
131 ; CHECK-PIC-NEXT: ldr x9, lptr
132 ; CHECK-PIC-NEXT: ldrb w8, [x8]
133 ; CHECK-PIC-NEXT: strb w8, [x9]
134 ; CHECK-PIC-NEXT: ret
136 ; CHECK-PIC-GLOBISEL-LABEL: bar3:
137 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
138 ; CHECK-PIC-GLOBISEL-NEXT: adr x8, lsrc
139 ; CHECK-PIC-GLOBISEL-NEXT: adr x9, lptr
140 ; CHECK-PIC-GLOBISEL-NEXT: ldrb w8, [x8]
141 ; CHECK-PIC-GLOBISEL-NEXT: ldr x9, [x9]
142 ; CHECK-PIC-GLOBISEL-NEXT: strb w8, [x9]
143 ; CHECK-PIC-GLOBISEL-NEXT: ret
145 %0 = load i8, ptr @lsrc, align 4
146 %1 = load ptr, ptr @lptr, align 8
147 store i8 %0, ptr %1, align 1
152 @lbsrc = internal global [65536 x i8] zeroinitializer, align 4
153 @lbdst = internal global [65536 x i8] zeroinitializer, align 4
155 define dso_preemptable void @baz1() {
156 ; CHECK-PIC-LABEL: baz1:
157 ; CHECK-PIC: // %bb.0: // %entry
158 ; CHECK-PIC-NEXT: adr x8, lbsrc
159 ; CHECK-PIC-NEXT: adr x9, lbdst
160 ; CHECK-PIC-NEXT: ldrb w8, [x8]
161 ; CHECK-PIC-NEXT: strb w8, [x9]
162 ; CHECK-PIC-NEXT: ret
164 ; CHECK-PIC-GLOBISEL-LABEL: baz1:
165 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
166 ; CHECK-PIC-GLOBISEL-NEXT: adr x8, lbsrc
167 ; CHECK-PIC-GLOBISEL-NEXT: adr x9, lbdst
168 ; CHECK-PIC-GLOBISEL-NEXT: ldrb w8, [x8]
169 ; CHECK-PIC-GLOBISEL-NEXT: strb w8, [x9]
170 ; CHECK-PIC-GLOBISEL-NEXT: ret
172 %0 = load i8, ptr @lbsrc, align 4
173 store i8 %0, ptr @lbdst, align 4
177 define dso_preemptable void @baz2() {
178 ; CHECK-PIC-LABEL: baz2:
179 ; CHECK-PIC: // %bb.0: // %entry
180 ; CHECK-PIC-NEXT: adr x8, lptr
181 ; CHECK-PIC-NEXT: adr x9, lbdst
182 ; CHECK-PIC-NEXT: str x9, [x8]
183 ; CHECK-PIC-NEXT: ret
185 ; CHECK-PIC-GLOBISEL-LABEL: baz2:
186 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
187 ; CHECK-PIC-GLOBISEL-NEXT: adr x8, lptr
188 ; CHECK-PIC-GLOBISEL-NEXT: adr x9, lbdst
189 ; CHECK-PIC-GLOBISEL-NEXT: str x9, [x8]
190 ; CHECK-PIC-GLOBISEL-NEXT: ret
192 store ptr @lbdst, ptr @lptr, align 8
196 define dso_preemptable void @baz3() {
197 ; FIXME: Needn't adr lptr
199 ; CHECK-PIC-LABEL: baz3:
200 ; CHECK-PIC: // %bb.0: // %entry
201 ; CHECK-PIC-NEXT: adr x8, lbsrc
202 ; CHECK-PIC-NEXT: ldr x9, lptr
203 ; CHECK-PIC-NEXT: ldrb w8, [x8]
204 ; CHECK-PIC-NEXT: strb w8, [x9]
205 ; CHECK-PIC-NEXT: ret
207 ; CHECK-PIC-GLOBISEL-LABEL: baz3:
208 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
209 ; CHECK-PIC-GLOBISEL-NEXT: adr x8, lbsrc
210 ; CHECK-PIC-GLOBISEL-NEXT: adr x9, lptr
211 ; CHECK-PIC-GLOBISEL-NEXT: ldrb w8, [x8]
212 ; CHECK-PIC-GLOBISEL-NEXT: ldr x9, [x9]
213 ; CHECK-PIC-GLOBISEL-NEXT: strb w8, [x9]
214 ; CHECK-PIC-GLOBISEL-NEXT: ret
216 %0 = load i8, ptr @lbsrc, align 4
217 %1 = load ptr, ptr @lptr, align 8
218 store i8 %0, ptr %1, align 1
223 declare void @func(...)
225 define dso_preemptable ptr @externfuncaddr() {
226 ; CHECK-PIC-LABEL: externfuncaddr:
227 ; CHECK-PIC: // %bb.0: // %entry
228 ; CHECK-PIC-NEXT: ldr x0, :got:func
229 ; CHECK-PIC-NEXT: ret
231 ; CHECK-PIC-GLOBISEL-LABEL: externfuncaddr:
232 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
233 ; CHECK-PIC-GLOBISEL-NEXT: ldr x0, :got:func
234 ; CHECK-PIC-GLOBISEL-NEXT: ret
239 define dso_preemptable ptr @localfuncaddr() {
240 ; CHECK-PIC-LABEL: localfuncaddr:
241 ; CHECK-PIC: // %bb.0: // %entry
242 ; CHECK-PIC-NEXT: ldr x0, :got:externfuncaddr
243 ; CHECK-PIC-NEXT: ret
245 ; CHECK-PIC-GLOBISEL-LABEL: localfuncaddr:
246 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
247 ; CHECK-PIC-GLOBISEL-NEXT: ldr x0, :got:externfuncaddr
248 ; CHECK-PIC-GLOBISEL-NEXT: ret
250 ret ptr @externfuncaddr