1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -o - -mtriple=aarch64-none-linux-gnu -code-model=tiny < %s | FileCheck %s
3 ; RUN: llc -verify-machineinstrs -o - -mtriple=aarch64-none-linux-gnu -code-model=tiny -fast-isel < %s | FileCheck %s
4 ; RUN: llc -verify-machineinstrs -o - -mtriple=aarch64-none-linux-gnu -code-model=tiny -global-isel < %s | FileCheck %s --check-prefix=CHECK-GLOBISEL
5 ; RUN: llc -verify-machineinstrs -o - -mtriple=aarch64-none-linux-gnu -code-model=tiny -relocation-model=pic < %s | FileCheck %s --check-prefix=CHECK-PIC
6 ; RUN: llc -verify-machineinstrs -o - -mtriple=aarch64-none-linux-gnu -code-model=tiny -relocation-model=pic -fast-isel < %s | FileCheck %s --check-prefix=CHECK-PIC
7 ; RUN: llc -verify-machineinstrs -o - -mtriple=aarch64-none-linux-gnu -code-model=tiny -relocation-model=pic -global-isel < %s | FileCheck %s --check-prefix=CHECK-PIC-GLOBISEL
9 ; Note fast-isel tests here will fall back to isel
11 @src = external local_unnamed_addr global [65536 x i8], align 1
12 @dst = external global [65536 x i8], align 1
13 @ptr = external local_unnamed_addr global i8*, align 8
17 ; CHECK: // %bb.0: // %entry
18 ; CHECK-NEXT: adr x8, src
19 ; CHECK-NEXT: ldrb w8, [x8]
20 ; CHECK-NEXT: adr x9, dst
21 ; CHECK-NEXT: strb w8, [x9]
24 ; CHECK-GLOBISEL-LABEL: foo1:
25 ; CHECK-GLOBISEL: // %bb.0: // %entry
26 ; CHECK-GLOBISEL-NEXT: adr x8, src
27 ; CHECK-GLOBISEL-NEXT: ldrb w8, [x8]
28 ; CHECK-GLOBISEL-NEXT: adr x9, dst
29 ; CHECK-GLOBISEL-NEXT: strb w8, [x9]
30 ; CHECK-GLOBISEL-NEXT: ret
32 ; CHECK-PIC-LABEL: foo1:
33 ; CHECK-PIC: // %bb.0: // %entry
34 ; CHECK-PIC-NEXT: ldr x8, :got:src
35 ; CHECK-PIC-NEXT: ldrb w8, [x8]
36 ; CHECK-PIC-NEXT: ldr x9, :got:dst
37 ; CHECK-PIC-NEXT: strb w8, [x9]
40 ; CHECK-PIC-GLOBISEL-LABEL: foo1:
41 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
42 ; CHECK-PIC-GLOBISEL-NEXT: ldr x8, :got:src
43 ; CHECK-PIC-GLOBISEL-NEXT: ldrb w8, [x8]
44 ; CHECK-PIC-GLOBISEL-NEXT: ldr x9, :got:dst
45 ; CHECK-PIC-GLOBISEL-NEXT: strb w8, [x9]
46 ; CHECK-PIC-GLOBISEL-NEXT: ret
48 %0 = load i8, i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @src, i64 0, i64 0), align 1
49 store i8 %0, i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @dst, i64 0, i64 0), align 1
55 ; CHECK: // %bb.0: // %entry
56 ; CHECK-NEXT: adr x8, ptr
57 ; CHECK-NEXT: adr x9, dst
58 ; CHECK-NEXT: str x9, [x8]
61 ; CHECK-GLOBISEL-LABEL: foo2:
62 ; CHECK-GLOBISEL: // %bb.0: // %entry
63 ; CHECK-GLOBISEL-NEXT: adr x8, dst
64 ; CHECK-GLOBISEL-NEXT: adr x9, ptr
65 ; CHECK-GLOBISEL-NEXT: str x8, [x9]
66 ; CHECK-GLOBISEL-NEXT: ret
68 ; CHECK-PIC-LABEL: foo2:
69 ; CHECK-PIC: // %bb.0: // %entry
70 ; CHECK-PIC-NEXT: ldr x8, :got:ptr
71 ; CHECK-PIC-NEXT: ldr x9, :got:dst
72 ; CHECK-PIC-NEXT: str x9, [x8]
75 ; CHECK-PIC-GLOBISEL-LABEL: foo2:
76 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
77 ; CHECK-PIC-GLOBISEL-NEXT: ldr x8, :got:dst
78 ; CHECK-PIC-GLOBISEL-NEXT: ldr x9, :got:ptr
79 ; CHECK-PIC-GLOBISEL-NEXT: str x8, [x9]
80 ; CHECK-PIC-GLOBISEL-NEXT: ret
82 store i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @dst, i64 0, i64 0), i8** @ptr, align 8
87 ; FIXME: Needn't adr ptr
90 ; CHECK: // %bb.0: // %entry
91 ; CHECK-NEXT: adr x8, src
92 ; CHECK-NEXT: ldrb w8, [x8]
93 ; CHECK-NEXT: ldr x9, ptr
94 ; CHECK-NEXT: strb w8, [x9]
97 ; CHECK-GLOBISEL-LABEL: foo3:
98 ; CHECK-GLOBISEL: // %bb.0: // %entry
99 ; CHECK-GLOBISEL-NEXT: adr x8, src
100 ; CHECK-GLOBISEL-NEXT: adr x9, ptr
101 ; CHECK-GLOBISEL-NEXT: ldrb w8, [x8]
102 ; CHECK-GLOBISEL-NEXT: ldr x9, [x9]
103 ; CHECK-GLOBISEL-NEXT: strb w8, [x9]
104 ; CHECK-GLOBISEL-NEXT: ret
106 ; CHECK-PIC-LABEL: foo3:
107 ; CHECK-PIC: // %bb.0: // %entry
108 ; CHECK-PIC-NEXT: ldr x8, :got:src
109 ; CHECK-PIC-NEXT: ldr x9, :got:ptr
110 ; CHECK-PIC-NEXT: ldrb w8, [x8]
111 ; CHECK-PIC-NEXT: ldr x9, [x9]
112 ; CHECK-PIC-NEXT: strb w8, [x9]
113 ; CHECK-PIC-NEXT: ret
115 ; CHECK-PIC-GLOBISEL-LABEL: foo3:
116 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
117 ; CHECK-PIC-GLOBISEL-NEXT: ldr x8, :got:src
118 ; CHECK-PIC-GLOBISEL-NEXT: ldr x9, :got:ptr
119 ; CHECK-PIC-GLOBISEL-NEXT: ldrb w8, [x8]
120 ; CHECK-PIC-GLOBISEL-NEXT: ldr x9, [x9]
121 ; CHECK-PIC-GLOBISEL-NEXT: strb w8, [x9]
122 ; CHECK-PIC-GLOBISEL-NEXT: ret
124 %0 = load i8, i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @src, i64 0, i64 0), align 1
125 %1 = load i8*, i8** @ptr, align 8
126 store i8 %0, i8* %1, align 1
130 @lsrc = internal global i8 0, align 4
131 @ldst = internal global i8 0, align 4
132 @lptr = internal global i8* null, align 8
134 define void @bar1() {
136 ; CHECK: // %bb.0: // %entry
137 ; CHECK-NEXT: adr x8, lsrc
138 ; CHECK-NEXT: ldrb w8, [x8]
139 ; CHECK-NEXT: adr x9, ldst
140 ; CHECK-NEXT: strb w8, [x9]
143 ; CHECK-GLOBISEL-LABEL: bar1:
144 ; CHECK-GLOBISEL: // %bb.0: // %entry
145 ; CHECK-GLOBISEL-NEXT: adr x8, lsrc
146 ; CHECK-GLOBISEL-NEXT: ldrb w8, [x8]
147 ; CHECK-GLOBISEL-NEXT: adr x9, ldst
148 ; CHECK-GLOBISEL-NEXT: strb w8, [x9]
149 ; CHECK-GLOBISEL-NEXT: ret
151 ; CHECK-PIC-LABEL: bar1:
152 ; CHECK-PIC: // %bb.0: // %entry
153 ; CHECK-PIC-NEXT: adr x8, lsrc
154 ; CHECK-PIC-NEXT: ldrb w8, [x8]
155 ; CHECK-PIC-NEXT: adr x9, ldst
156 ; CHECK-PIC-NEXT: strb w8, [x9]
157 ; CHECK-PIC-NEXT: ret
159 ; CHECK-PIC-GLOBISEL-LABEL: bar1:
160 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
161 ; CHECK-PIC-GLOBISEL-NEXT: adr x8, lsrc
162 ; CHECK-PIC-GLOBISEL-NEXT: ldrb w8, [x8]
163 ; CHECK-PIC-GLOBISEL-NEXT: adr x9, ldst
164 ; CHECK-PIC-GLOBISEL-NEXT: strb w8, [x9]
165 ; CHECK-PIC-GLOBISEL-NEXT: ret
167 %0 = load i8, i8* @lsrc, align 4
168 store i8 %0, i8* @ldst, align 4
172 define void @bar2() {
174 ; CHECK: // %bb.0: // %entry
175 ; CHECK-NEXT: adr x8, lptr
176 ; CHECK-NEXT: adr x9, ldst
177 ; CHECK-NEXT: str x9, [x8]
180 ; CHECK-GLOBISEL-LABEL: bar2:
181 ; CHECK-GLOBISEL: // %bb.0: // %entry
182 ; CHECK-GLOBISEL-NEXT: adr x8, ldst
183 ; CHECK-GLOBISEL-NEXT: adr x9, lptr
184 ; CHECK-GLOBISEL-NEXT: str x8, [x9]
185 ; CHECK-GLOBISEL-NEXT: ret
187 ; CHECK-PIC-LABEL: bar2:
188 ; CHECK-PIC: // %bb.0: // %entry
189 ; CHECK-PIC-NEXT: adr x8, lptr
190 ; CHECK-PIC-NEXT: adr x9, ldst
191 ; CHECK-PIC-NEXT: str x9, [x8]
192 ; CHECK-PIC-NEXT: ret
194 ; CHECK-PIC-GLOBISEL-LABEL: bar2:
195 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
196 ; CHECK-PIC-GLOBISEL-NEXT: adr x8, ldst
197 ; CHECK-PIC-GLOBISEL-NEXT: adr x9, lptr
198 ; CHECK-PIC-GLOBISEL-NEXT: str x8, [x9]
199 ; CHECK-PIC-GLOBISEL-NEXT: ret
201 store i8* @ldst, i8** @lptr, align 8
205 define void @bar3() {
206 ; FIXME: Needn't adr lptr
209 ; CHECK: // %bb.0: // %entry
210 ; CHECK-NEXT: adr x8, lsrc
211 ; CHECK-NEXT: ldrb w8, [x8]
212 ; CHECK-NEXT: ldr x9, lptr
213 ; CHECK-NEXT: strb w8, [x9]
216 ; CHECK-GLOBISEL-LABEL: bar3:
217 ; CHECK-GLOBISEL: // %bb.0: // %entry
218 ; CHECK-GLOBISEL-NEXT: adr x8, lsrc
219 ; CHECK-GLOBISEL-NEXT: adr x9, lptr
220 ; CHECK-GLOBISEL-NEXT: ldrb w8, [x8]
221 ; CHECK-GLOBISEL-NEXT: ldr x9, [x9]
222 ; CHECK-GLOBISEL-NEXT: strb w8, [x9]
223 ; CHECK-GLOBISEL-NEXT: ret
225 ; CHECK-PIC-LABEL: bar3:
226 ; CHECK-PIC: // %bb.0: // %entry
227 ; CHECK-PIC-NEXT: adr x8, lsrc
228 ; CHECK-PIC-NEXT: ldrb w8, [x8]
229 ; CHECK-PIC-NEXT: ldr x9, lptr
230 ; CHECK-PIC-NEXT: strb w8, [x9]
231 ; CHECK-PIC-NEXT: ret
233 ; CHECK-PIC-GLOBISEL-LABEL: bar3:
234 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
235 ; CHECK-PIC-GLOBISEL-NEXT: adr x8, lsrc
236 ; CHECK-PIC-GLOBISEL-NEXT: adr x9, lptr
237 ; CHECK-PIC-GLOBISEL-NEXT: ldrb w8, [x8]
238 ; CHECK-PIC-GLOBISEL-NEXT: ldr x9, [x9]
239 ; CHECK-PIC-GLOBISEL-NEXT: strb w8, [x9]
240 ; CHECK-PIC-GLOBISEL-NEXT: ret
242 %0 = load i8, i8* @lsrc, align 4
243 %1 = load i8*, i8** @lptr, align 8
244 store i8 %0, i8* %1, align 1
249 @lbsrc = internal global [65536 x i8] zeroinitializer, align 4
250 @lbdst = internal global [65536 x i8] zeroinitializer, align 4
252 define void @baz1() {
254 ; CHECK: // %bb.0: // %entry
255 ; CHECK-NEXT: adr x8, lbsrc
256 ; CHECK-NEXT: ldrb w8, [x8]
257 ; CHECK-NEXT: adr x9, lbdst
258 ; CHECK-NEXT: strb w8, [x9]
261 ; CHECK-GLOBISEL-LABEL: baz1:
262 ; CHECK-GLOBISEL: // %bb.0: // %entry
263 ; CHECK-GLOBISEL-NEXT: adr x8, lbsrc
264 ; CHECK-GLOBISEL-NEXT: ldrb w8, [x8]
265 ; CHECK-GLOBISEL-NEXT: adr x9, lbdst
266 ; CHECK-GLOBISEL-NEXT: strb w8, [x9]
267 ; CHECK-GLOBISEL-NEXT: ret
269 ; CHECK-PIC-LABEL: baz1:
270 ; CHECK-PIC: // %bb.0: // %entry
271 ; CHECK-PIC-NEXT: adr x8, lbsrc
272 ; CHECK-PIC-NEXT: ldrb w8, [x8]
273 ; CHECK-PIC-NEXT: adr x9, lbdst
274 ; CHECK-PIC-NEXT: strb w8, [x9]
275 ; CHECK-PIC-NEXT: ret
277 ; CHECK-PIC-GLOBISEL-LABEL: baz1:
278 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
279 ; CHECK-PIC-GLOBISEL-NEXT: adr x8, lbsrc
280 ; CHECK-PIC-GLOBISEL-NEXT: ldrb w8, [x8]
281 ; CHECK-PIC-GLOBISEL-NEXT: adr x9, lbdst
282 ; CHECK-PIC-GLOBISEL-NEXT: strb w8, [x9]
283 ; CHECK-PIC-GLOBISEL-NEXT: ret
285 %0 = load i8, i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @lbsrc, i64 0, i64 0), align 4
286 store i8 %0, i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @lbdst, i64 0, i64 0), align 4
290 define void @baz2() {
292 ; CHECK: // %bb.0: // %entry
293 ; CHECK-NEXT: adr x8, lptr
294 ; CHECK-NEXT: adr x9, lbdst
295 ; CHECK-NEXT: str x9, [x8]
298 ; CHECK-GLOBISEL-LABEL: baz2:
299 ; CHECK-GLOBISEL: // %bb.0: // %entry
300 ; CHECK-GLOBISEL-NEXT: adr x8, lbdst
301 ; CHECK-GLOBISEL-NEXT: adr x9, lptr
302 ; CHECK-GLOBISEL-NEXT: str x8, [x9]
303 ; CHECK-GLOBISEL-NEXT: ret
305 ; CHECK-PIC-LABEL: baz2:
306 ; CHECK-PIC: // %bb.0: // %entry
307 ; CHECK-PIC-NEXT: adr x8, lptr
308 ; CHECK-PIC-NEXT: adr x9, lbdst
309 ; CHECK-PIC-NEXT: str x9, [x8]
310 ; CHECK-PIC-NEXT: ret
312 ; CHECK-PIC-GLOBISEL-LABEL: baz2:
313 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
314 ; CHECK-PIC-GLOBISEL-NEXT: adr x8, lbdst
315 ; CHECK-PIC-GLOBISEL-NEXT: adr x9, lptr
316 ; CHECK-PIC-GLOBISEL-NEXT: str x8, [x9]
317 ; CHECK-PIC-GLOBISEL-NEXT: ret
319 store i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @lbdst, i64 0, i64 0), i8** @lptr, align 8
323 define void @baz3() {
324 ; FIXME: Needn't adr lptr
327 ; CHECK: // %bb.0: // %entry
328 ; CHECK-NEXT: adr x8, lbsrc
329 ; CHECK-NEXT: ldrb w8, [x8]
330 ; CHECK-NEXT: ldr x9, lptr
331 ; CHECK-NEXT: strb w8, [x9]
334 ; CHECK-GLOBISEL-LABEL: baz3:
335 ; CHECK-GLOBISEL: // %bb.0: // %entry
336 ; CHECK-GLOBISEL-NEXT: adr x8, lbsrc
337 ; CHECK-GLOBISEL-NEXT: adr x9, lptr
338 ; CHECK-GLOBISEL-NEXT: ldrb w8, [x8]
339 ; CHECK-GLOBISEL-NEXT: ldr x9, [x9]
340 ; CHECK-GLOBISEL-NEXT: strb w8, [x9]
341 ; CHECK-GLOBISEL-NEXT: ret
343 ; CHECK-PIC-LABEL: baz3:
344 ; CHECK-PIC: // %bb.0: // %entry
345 ; CHECK-PIC-NEXT: adr x8, lbsrc
346 ; CHECK-PIC-NEXT: ldrb w8, [x8]
347 ; CHECK-PIC-NEXT: ldr x9, lptr
348 ; CHECK-PIC-NEXT: strb w8, [x9]
349 ; CHECK-PIC-NEXT: ret
351 ; CHECK-PIC-GLOBISEL-LABEL: baz3:
352 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
353 ; CHECK-PIC-GLOBISEL-NEXT: adr x8, lbsrc
354 ; CHECK-PIC-GLOBISEL-NEXT: adr x9, lptr
355 ; CHECK-PIC-GLOBISEL-NEXT: ldrb w8, [x8]
356 ; CHECK-PIC-GLOBISEL-NEXT: ldr x9, [x9]
357 ; CHECK-PIC-GLOBISEL-NEXT: strb w8, [x9]
358 ; CHECK-PIC-GLOBISEL-NEXT: ret
360 %0 = load i8, i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @lbsrc, i64 0, i64 0), align 4
361 %1 = load i8*, i8** @lptr, align 8
362 store i8 %0, i8* %1, align 1
367 declare void @func(...)
369 define i8* @externfuncaddr() {
370 ; CHECK-LABEL: externfuncaddr:
371 ; CHECK: // %bb.0: // %entry
372 ; CHECK-NEXT: adr x0, func
375 ; CHECK-GLOBISEL-LABEL: externfuncaddr:
376 ; CHECK-GLOBISEL: // %bb.0: // %entry
377 ; CHECK-GLOBISEL-NEXT: adr x0, func
378 ; CHECK-GLOBISEL-NEXT: ret
380 ; CHECK-PIC-LABEL: externfuncaddr:
381 ; CHECK-PIC: // %bb.0: // %entry
382 ; CHECK-PIC-NEXT: ldr x0, :got:func
383 ; CHECK-PIC-NEXT: ret
385 ; CHECK-PIC-GLOBISEL-LABEL: externfuncaddr:
386 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
387 ; CHECK-PIC-GLOBISEL-NEXT: ldr x0, :got:func
388 ; CHECK-PIC-GLOBISEL-NEXT: ret
390 ret i8* bitcast (void (...)* @func to i8*)
393 define i8* @localfuncaddr() {
394 ; CHECK-LABEL: localfuncaddr:
395 ; CHECK: // %bb.0: // %entry
396 ; CHECK-NEXT: adr x0, externfuncaddr
399 ; CHECK-GLOBISEL-LABEL: localfuncaddr:
400 ; CHECK-GLOBISEL: // %bb.0: // %entry
401 ; CHECK-GLOBISEL-NEXT: adr x0, externfuncaddr
402 ; CHECK-GLOBISEL-NEXT: ret
404 ; CHECK-PIC-LABEL: localfuncaddr:
405 ; CHECK-PIC: // %bb.0: // %entry
406 ; CHECK-PIC-NEXT: ldr x0, :got:externfuncaddr
407 ; CHECK-PIC-NEXT: ret
409 ; CHECK-PIC-GLOBISEL-LABEL: localfuncaddr:
410 ; CHECK-PIC-GLOBISEL: // %bb.0: // %entry
411 ; CHECK-PIC-GLOBISEL-NEXT: ldr x0, :got:externfuncaddr
412 ; CHECK-PIC-GLOBISEL-NEXT: ret
414 ret i8* bitcast (i8* ()* @externfuncaddr to i8*)