1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64 -relocation-model=static < %s | FileCheck %s --check-prefixes=CHECK,STATIC
3 ; RUN: llc -mtriple=aarch64 -relocation-model=pic < %s | FileCheck %s --check-prefixes=CHECK,PIC
5 @preemptable_var = dso_preemptable global i32 42
6 define ptr @get_preemptable_var() nounwind {
7 ; CHECK-LABEL: get_preemptable_var:
9 ; CHECK-NEXT: adrp x0, :got:preemptable_var
10 ; CHECK-NEXT: ldr x0, [x0, :got_lo12:preemptable_var]
12 ret ptr @preemptable_var
15 @dsolocal_var = dso_local global i32 42
16 define ptr @get_dsolocal_var() nounwind {
17 ; STATIC-LABEL: get_dsolocal_var:
19 ; STATIC-NEXT: adrp x0, dsolocal_var
20 ; STATIC-NEXT: add x0, x0, :lo12:dsolocal_var
23 ; PIC-LABEL: get_dsolocal_var:
25 ; PIC-NEXT: adrp x0, .Ldsolocal_var$local
26 ; PIC-NEXT: add x0, x0, :lo12:.Ldsolocal_var$local
31 @weak_dsolocal_var = weak dso_local global i32 42
32 define ptr @get_weak_dsolocal_var() nounwind {
33 ; CHECK-LABEL: get_weak_dsolocal_var:
35 ; CHECK-NEXT: adrp x0, weak_dsolocal_var
36 ; CHECK-NEXT: add x0, x0, :lo12:weak_dsolocal_var
38 ret ptr @weak_dsolocal_var
41 @hidden_var = hidden global i32 42
42 define ptr @get_hidden_var() nounwind {
43 ; CHECK-LABEL: get_hidden_var:
45 ; CHECK-NEXT: adrp x0, hidden_var
46 ; CHECK-NEXT: add x0, x0, :lo12:hidden_var
51 @protected_var = protected global i32 42
52 define ptr @get_protected_var() nounwind {
53 ; CHECK-LABEL: get_protected_var:
55 ; CHECK-NEXT: adrp x0, protected_var
56 ; CHECK-NEXT: add x0, x0, :lo12:protected_var
58 ret ptr @protected_var
61 define dso_preemptable ptr @preemptable_func() nounwind {
62 ; CHECK-LABEL: preemptable_func:
64 ; CHECK-NEXT: adrp x0, :got:preemptable_func
65 ; CHECK-NEXT: ldr x0, [x0, :got_lo12:preemptable_func]
67 ret ptr @preemptable_func
70 define dso_local ptr @dsolocal_func() nounwind {
71 ; STATIC-LABEL: dsolocal_func:
73 ; STATIC-NEXT: adrp x0, dsolocal_func
74 ; STATIC-NEXT: add x0, x0, :lo12:dsolocal_func
77 ; PIC-LABEL: dsolocal_func:
78 ; PIC: .Ldsolocal_func$local:
79 ; PIC-NEXT: .type .Ldsolocal_func$local,@function
81 ; PIC-NEXT: adrp x0, .Ldsolocal_func$local
82 ; PIC-NEXT: add x0, x0, :lo12:.Ldsolocal_func$local
84 ret ptr @dsolocal_func
87 ; PIC: [[END_LABEL:.Lfunc_end.+]]:
88 ; PIC-NEXT: .size dsolocal_func, [[END_LABEL]]-dsolocal_func
89 ; PIC-NEXT: .size .Ldsolocal_func$local, [[END_LABEL]]-dsolocal_func
92 define weak dso_local ptr @weak_dsolocal_func() nounwind {
93 ; CHECK-LABEL: weak_dsolocal_func:
95 ; CHECK-NEXT: adrp x0, weak_dsolocal_func
96 ; CHECK-NEXT: add x0, x0, :lo12:weak_dsolocal_func
98 ret ptr @weak_dsolocal_func
101 ;; bl .Ldsolocal_func$local either resolves to a constant at assembly time
102 ;; or produces a relocation which can potentially cause a veneer.
103 define dso_local void @call_dsolocal_func() nounwind {
104 ; STATIC-LABEL: call_dsolocal_func:
106 ; STATIC-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
107 ; STATIC-NEXT: bl dsolocal_func
108 ; STATIC-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
111 ; PIC-LABEL: call_dsolocal_func:
112 ; PIC: .Lcall_dsolocal_func$local:
113 ; PIC-NEXT: .type .Lcall_dsolocal_func$local,@function
114 ; PIC-NEXT: // %bb.0:
115 ; PIC-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
116 ; PIC-NEXT: bl .Ldsolocal_func$local
117 ; PIC-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
119 call ptr @dsolocal_func()
122 ; UTC-ARGS: --disable
123 ; PIC: [[END_LABEL:.Lfunc_end.+]]:
124 ; PIC-NEXT: .size call_dsolocal_func, [[END_LABEL]]-call_dsolocal_func
125 ; PIC-NEXT: .size .Lcall_dsolocal_func$local, [[END_LABEL]]-call_dsolocal_func