1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=armv7-linux-gnueabi -relocation-model=static < %s \
3 ; RUN: | FileCheck %s --check-prefix=STATIC
4 ; RUN: llc -mtriple=armv7-linux-gnueabi -relocation-model=pic < %s \
5 ; RUN: | FileCheck %s --check-prefix=PIC
7 @preemptable_var = dso_preemptable global i32 42
8 define ptr @get_preemptable_var() nounwind {
9 ; STATIC-LABEL: get_preemptable_var:
11 ; STATIC-NEXT: movw r0, :lower16:preemptable_var
12 ; STATIC-NEXT: movt r0, :upper16:preemptable_var
15 ; PIC-LABEL: get_preemptable_var:
17 ; PIC-NEXT: ldr r0, .LCPI0_0
19 ; PIC-NEXT: ldr r0, [pc, r0]
21 ; PIC-NEXT: .p2align 2
25 ; PIC-NEXT: .long preemptable_var(GOT_PREL)-((.LPC0_0+8)-.Ltmp0)
26 ret ptr @preemptable_var
29 @dsolocal_var = dso_local global i32 42
30 define ptr @get_dsolocal_var() nounwind {
31 ; STATIC-LABEL: get_dsolocal_var:
33 ; STATIC-NEXT: movw r0, :lower16:dsolocal_var
34 ; STATIC-NEXT: movt r0, :upper16:dsolocal_var
37 ; PIC-LABEL: get_dsolocal_var:
39 ; PIC-NEXT: ldr r0, .LCPI1_0
41 ; PIC-NEXT: add r0, pc, r0
43 ; PIC-NEXT: .p2align 2
46 ; PIC-NEXT: .long .Ldsolocal_var$local-(.LPC1_0+8)
50 @weak_dsolocal_var = weak dso_local global i32 42
51 define ptr @get_weak_dsolocal_var() nounwind {
52 ; STATIC-LABEL: get_weak_dsolocal_var:
54 ; STATIC-NEXT: movw r0, :lower16:weak_dsolocal_var
55 ; STATIC-NEXT: movt r0, :upper16:weak_dsolocal_var
58 ; PIC-LABEL: get_weak_dsolocal_var:
60 ; PIC-NEXT: ldr r0, .LCPI2_0
62 ; PIC-NEXT: add r0, pc, r0
64 ; PIC-NEXT: .p2align 2
67 ; PIC-NEXT: .long weak_dsolocal_var-(.LPC2_0+8)
68 ret ptr @weak_dsolocal_var
71 @hidden_var = hidden global i32 42
72 define ptr @get_hidden_var() nounwind {
73 ; STATIC-LABEL: get_hidden_var:
75 ; STATIC-NEXT: movw r0, :lower16:hidden_var
76 ; STATIC-NEXT: movt r0, :upper16:hidden_var
79 ; PIC-LABEL: get_hidden_var:
81 ; PIC-NEXT: ldr r0, .LCPI3_0
83 ; PIC-NEXT: add r0, pc, r0
85 ; PIC-NEXT: .p2align 2
88 ; PIC-NEXT: .long hidden_var-(.LPC3_0+8)
92 @protected_var = protected global i32 42
93 define ptr @get_protected_var() nounwind {
94 ; STATIC-LABEL: get_protected_var:
96 ; STATIC-NEXT: movw r0, :lower16:protected_var
97 ; STATIC-NEXT: movt r0, :upper16:protected_var
100 ; PIC-LABEL: get_protected_var:
102 ; PIC-NEXT: ldr r0, .LCPI4_0
104 ; PIC-NEXT: add r0, pc, r0
106 ; PIC-NEXT: .p2align 2
108 ; PIC-NEXT: .LCPI4_0:
109 ; PIC-NEXT: .long protected_var-(.LPC4_0+8)
110 ret ptr @protected_var
113 define dso_preemptable ptr @preemptable_func() nounwind {
114 ; STATIC-LABEL: preemptable_func:
116 ; STATIC-NEXT: movw r0, :lower16:preemptable_func
117 ; STATIC-NEXT: movt r0, :upper16:preemptable_func
120 ; PIC-LABEL: preemptable_func:
122 ; PIC-NEXT: ldr r0, .LCPI5_0
124 ; PIC-NEXT: ldr r0, [pc, r0]
126 ; PIC-NEXT: .p2align 2
128 ; PIC-NEXT: .LCPI5_0:
130 ; PIC-NEXT: .long preemptable_func(GOT_PREL)-((.LPC5_0+8)-.Ltmp1)
131 ret ptr @preemptable_func
134 define dso_local ptr @dsolocal_func() nounwind {
135 ; STATIC-LABEL: dsolocal_func:
137 ; STATIC-NEXT: movw r0, :lower16:dsolocal_func
138 ; STATIC-NEXT: movt r0, :upper16:dsolocal_func
141 ; PIC-LABEL: dsolocal_func:
143 ; PIC-NEXT: ldr r0, .LCPI6_0
145 ; PIC-NEXT: add r0, pc, r0
147 ; PIC-NEXT: .p2align 2
149 ; PIC-NEXT: .LCPI6_0:
150 ; PIC-NEXT: .long .Ldsolocal_func$local-(.LPC6_0+8)
151 ret ptr @dsolocal_func
154 define weak dso_local ptr @weak_dsolocal_func() nounwind {
155 ; STATIC-LABEL: weak_dsolocal_func:
157 ; STATIC-NEXT: movw r0, :lower16:weak_dsolocal_func
158 ; STATIC-NEXT: movt r0, :upper16:weak_dsolocal_func
161 ; PIC-LABEL: weak_dsolocal_func:
163 ; PIC-NEXT: ldr r0, .LCPI7_0
165 ; PIC-NEXT: add r0, pc, r0
167 ; PIC-NEXT: .p2align 2
169 ; PIC-NEXT: .LCPI7_0:
170 ; PIC-NEXT: .long weak_dsolocal_func-(.LPC7_0+8)
171 ret ptr @weak_dsolocal_func
174 ;; call .Ldsolocal_func$local either resolves to a constant at assembly time
175 ;; or produces a relocation referencing a non-preemptible local symbol.
176 define dso_local void @call_dsolocal_func() nounwind {
177 ; STATIC-LABEL: call_dsolocal_func:
179 ; STATIC-NEXT: .save {r11, lr}
180 ; STATIC-NEXT: push {r11, lr}
181 ; STATIC-NEXT: bl dsolocal_func
182 ; STATIC-NEXT: pop {r11, pc}
184 ; PIC-LABEL: call_dsolocal_func:
186 ; PIC-NEXT: .save {r11, lr}
187 ; PIC-NEXT: push {r11, lr}
188 ; PIC-NEXT: bl .Ldsolocal_func$local
189 ; PIC-NEXT: pop {r11, pc}
190 call ptr @dsolocal_func()