1 ; RUN: llc -mtriple=arm64 -relocation-model=pic -o - %s -mcpu=cyclone | FileCheck %s --check-prefix=CHECK-PIC
2 ; RUN: llc -mtriple=arm64 -O0 -fast-isel -relocation-model=pic -o - %s -mcpu=cyclone | FileCheck %s --check-prefix=CHECK-FAST-PIC
4 @var8 = external global i8, align 1
5 @var16 = external global i16, align 2
6 @var32 = external global i32, align 4
7 @var64 = external global i64, align 8
9 define i8 @test_i8(i8 %new) {
10 %val = load i8, ptr @var8, align 1
11 store i8 %new, ptr @var8
13 ; CHECK-PIC-LABEL: test_i8:
14 ; CHECK-PIC: adrp x[[HIREG:[0-9]+]], :got:var8
15 ; CHECK-PIC: ldr x[[VAR_ADDR:[0-9]+]], [x[[HIREG]], :got_lo12:var8]
16 ; CHECK-PIC: ldrb {{w[0-9]+}}, [x[[VAR_ADDR]]]
18 ; CHECK-FAST-PIC: adrp x[[HIREG:[0-9]+]], :got:var8
19 ; CHECK-FAST-PIC: ldr x[[VARADDR:[0-9]+]], [x[[HIREG]], :got_lo12:var8]
20 ; CHECK-FAST-PIC: ldr {{w[0-9]+}}, [x[[VARADDR]]]
23 define i16 @test_i16(i16 %new) {
24 %val = load i16, ptr @var16, align 2
25 store i16 %new, ptr @var16
29 define i32 @test_i32(i32 %new) {
30 %val = load i32, ptr @var32, align 4
31 store i32 %new, ptr @var32
35 define i64 @test_i64(i64 %new) {
36 %val = load i64, ptr @var64, align 8
37 store i64 %new, ptr @var64
41 define ptr @test_addr() {
45 @hiddenvar = hidden global i32 0, align 4
46 @protectedvar = protected global i32 0, align 4
48 define i32 @test_vis() {
49 %lhs = load i32, ptr @hiddenvar, align 4
50 %rhs = load i32, ptr @protectedvar, align 4
51 %ret = add i32 %lhs, %rhs
53 ; CHECK-PIC-LABEL: test_vis:
54 ; CHECK-PIC: adrp {{x[0-9]+}}, hiddenvar
55 ; CHECK-PIC: ldr {{w[0-9]+}}, [{{x[0-9]+}}, :lo12:hiddenvar]
56 ; CHECK-PIC: adrp {{x[0-9]+}}, protectedvar
57 ; CHECK-PIC: ldr {{w[0-9]+}}, [{{x[0-9]+}}, :lo12:protectedvar]
60 @var_default = external global [2 x i32]
62 define i32 @test_default_align() {
63 %val = load i32, ptr @var_default
67 define i64 @test_default_unaligned() {
68 %val = load i64, ptr @var_default