1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
2 ;; direct-access-external-data is false due to PIC Level, so __stack_chk_guard
3 ;; is dso_preemtable. Check that we use GOT PIC code sequence as well because
4 ;; R_ARM_GOT_ABS does not have assembler support.
5 ; RUN: llc -relocation-model=static < %s | FileCheck %s
6 ; RUN: llc -relocation-model=pic < %s | FileCheck %s
7 ;; Also check Thumb1 and Thumb2.
8 ; RUN: llc -mtriple=thumbv6-linux-gnueabi -relocation-model=static < %s | FileCheck %s --check-prefix=THUMB1
9 ; RUN: llc -mtriple=thumbv6-linux-gnueabi -relocation-model=pic < %s | FileCheck %s --check-prefix=THUMB1-PIC
10 ; RUN: llc -mtriple=thumbv7-linux-gnueabi -relocation-model=static < %s | FileCheck %s --check-prefix=THUMB2
11 ; RUN: llc -mtriple=thumbv7-linux-gnueabi -relocation-model=pic < %s | FileCheck %s --check-prefix=THUMB2-PIC
13 target triple = "armv7a-linux-gnueabi"
15 define i32 @test1() #0 {
18 ; CHECK-NEXT: push {r11, lr}
19 ; CHECK-NEXT: sub sp, sp, #8
20 ; CHECK-NEXT: sub sp, sp, #1024
21 ; CHECK-NEXT: ldr r0, .LCPI0_0
22 ; CHECK-NEXT: .LPC0_0:
23 ; CHECK-NEXT: add r0, pc, r0
24 ; CHECK-NEXT: ldr r0, [r0]
25 ; CHECK-NEXT: ldr r0, [r0]
26 ; CHECK-NEXT: str r0, [sp, #1028]
27 ; CHECK-NEXT: add r0, sp, #4
29 ; CHECK-NEXT: ldr r0, [sp, #1028]
30 ; CHECK-NEXT: ldr r1, .LCPI0_1
31 ; CHECK-NEXT: .LPC0_1:
32 ; CHECK-NEXT: add r1, pc, r1
33 ; CHECK-NEXT: ldr r1, [r1]
34 ; CHECK-NEXT: ldr r1, [r1]
35 ; CHECK-NEXT: cmp r1, r0
36 ; CHECK-NEXT: moveq r0, #0
37 ; CHECK-NEXT: addeq sp, sp, #8
38 ; CHECK-NEXT: addeq sp, sp, #1024
39 ; CHECK-NEXT: popeq {r11, pc}
40 ; CHECK-NEXT: .LBB0_1:
41 ; CHECK-NEXT: bl __stack_chk_fail
42 ; CHECK-NEXT: .p2align 2
43 ; CHECK-NEXT: @ %bb.2:
44 ; CHECK-NEXT: .LCPI0_0:
46 ; CHECK-NEXT: .long __stack_chk_guard(GOT_PREL)-((.LPC0_0+8)-.Ltmp0)
47 ; CHECK-NEXT: .LCPI0_1:
49 ; CHECK-NEXT: .long __stack_chk_guard(GOT_PREL)-((.LPC0_1+8)-.Ltmp1)
51 ; THUMB1-LABEL: test1:
53 ; THUMB1-NEXT: .save {r4, r5, r6, lr}
54 ; THUMB1-NEXT: push {r4, r5, r6, lr}
55 ; THUMB1-NEXT: .pad #508
56 ; THUMB1-NEXT: sub sp, #508
57 ; THUMB1-NEXT: .pad #508
58 ; THUMB1-NEXT: sub sp, #508
59 ; THUMB1-NEXT: .pad #16
60 ; THUMB1-NEXT: sub sp, #16
61 ; THUMB1-NEXT: ldr r0, .LCPI0_0
62 ; THUMB1-NEXT: .LPC0_0:
63 ; THUMB1-NEXT: add r0, pc
64 ; THUMB1-NEXT: ldr r0, [r0]
65 ; THUMB1-NEXT: ldr r0, [r0]
66 ; THUMB1-NEXT: add r1, sp, #904
67 ; THUMB1-NEXT: str r0, [r1, #124]
68 ; THUMB1-NEXT: add r0, sp, #4
70 ; THUMB1-NEXT: add r0, sp, #904
71 ; THUMB1-NEXT: ldr r0, [r0, #124]
72 ; THUMB1-NEXT: ldr r1, .LCPI0_1
73 ; THUMB1-NEXT: .LPC0_1:
74 ; THUMB1-NEXT: add r1, pc
75 ; THUMB1-NEXT: ldr r1, [r1]
76 ; THUMB1-NEXT: ldr r1, [r1]
77 ; THUMB1-NEXT: cmp r1, r0
78 ; THUMB1-NEXT: bne .LBB0_2
79 ; THUMB1-NEXT: @ %bb.1:
80 ; THUMB1-NEXT: movs r0, #0
81 ; THUMB1-NEXT: add sp, #508
82 ; THUMB1-NEXT: add sp, #508
83 ; THUMB1-NEXT: add sp, #16
84 ; THUMB1-NEXT: pop {r4, r5, r6, pc}
85 ; THUMB1-NEXT: .LBB0_2:
86 ; THUMB1-NEXT: bl __stack_chk_fail
87 ; THUMB1-NEXT: .p2align 2
88 ; THUMB1-NEXT: @ %bb.3:
89 ; THUMB1-NEXT: .LCPI0_0:
90 ; THUMB1-NEXT: .Ltmp0:
91 ; THUMB1-NEXT: .long __stack_chk_guard(GOT_PREL)-((.LPC0_0+4)-.Ltmp0)
92 ; THUMB1-NEXT: .LCPI0_1:
93 ; THUMB1-NEXT: .Ltmp1:
94 ; THUMB1-NEXT: .long __stack_chk_guard(GOT_PREL)-((.LPC0_1+4)-.Ltmp1)
96 ; THUMB1-PIC-LABEL: test1:
97 ; THUMB1-PIC: @ %bb.0:
98 ; THUMB1-PIC-NEXT: .save {r4, r5, r6, lr}
99 ; THUMB1-PIC-NEXT: push {r4, r5, r6, lr}
100 ; THUMB1-PIC-NEXT: .pad #508
101 ; THUMB1-PIC-NEXT: sub sp, #508
102 ; THUMB1-PIC-NEXT: .pad #508
103 ; THUMB1-PIC-NEXT: sub sp, #508
104 ; THUMB1-PIC-NEXT: .pad #16
105 ; THUMB1-PIC-NEXT: sub sp, #16
106 ; THUMB1-PIC-NEXT: ldr r0, .LCPI0_0
107 ; THUMB1-PIC-NEXT: .LPC0_0:
108 ; THUMB1-PIC-NEXT: add r0, pc
109 ; THUMB1-PIC-NEXT: ldr r0, [r0]
110 ; THUMB1-PIC-NEXT: ldr r0, [r0]
111 ; THUMB1-PIC-NEXT: add r1, sp, #904
112 ; THUMB1-PIC-NEXT: str r0, [r1, #124]
113 ; THUMB1-PIC-NEXT: add r0, sp, #4
114 ; THUMB1-PIC-NEXT: bl foo
115 ; THUMB1-PIC-NEXT: add r0, sp, #904
116 ; THUMB1-PIC-NEXT: ldr r0, [r0, #124]
117 ; THUMB1-PIC-NEXT: ldr r1, .LCPI0_1
118 ; THUMB1-PIC-NEXT: .LPC0_1:
119 ; THUMB1-PIC-NEXT: add r1, pc
120 ; THUMB1-PIC-NEXT: ldr r1, [r1]
121 ; THUMB1-PIC-NEXT: ldr r1, [r1]
122 ; THUMB1-PIC-NEXT: cmp r1, r0
123 ; THUMB1-PIC-NEXT: bne .LBB0_2
124 ; THUMB1-PIC-NEXT: @ %bb.1:
125 ; THUMB1-PIC-NEXT: movs r0, #0
126 ; THUMB1-PIC-NEXT: add sp, #508
127 ; THUMB1-PIC-NEXT: add sp, #508
128 ; THUMB1-PIC-NEXT: add sp, #16
129 ; THUMB1-PIC-NEXT: pop {r4, r5, r6, pc}
130 ; THUMB1-PIC-NEXT: .LBB0_2:
131 ; THUMB1-PIC-NEXT: bl __stack_chk_fail
132 ; THUMB1-PIC-NEXT: .p2align 2
133 ; THUMB1-PIC-NEXT: @ %bb.3:
134 ; THUMB1-PIC-NEXT: .LCPI0_0:
135 ; THUMB1-PIC-NEXT: .Ltmp0:
136 ; THUMB1-PIC-NEXT: .long __stack_chk_guard(GOT_PREL)-((.LPC0_0+4)-.Ltmp0)
137 ; THUMB1-PIC-NEXT: .LCPI0_1:
138 ; THUMB1-PIC-NEXT: .Ltmp1:
139 ; THUMB1-PIC-NEXT: .long __stack_chk_guard(GOT_PREL)-((.LPC0_1+4)-.Ltmp1)
141 ; THUMB2-LABEL: test1:
143 ; THUMB2-NEXT: .save {r7, lr}
144 ; THUMB2-NEXT: push {r7, lr}
145 ; THUMB2-NEXT: .pad #1032
146 ; THUMB2-NEXT: sub.w sp, sp, #1032
147 ; THUMB2-NEXT: ldr r0, .LCPI0_0
148 ; THUMB2-NEXT: .LPC0_0:
149 ; THUMB2-NEXT: add r0, pc
150 ; THUMB2-NEXT: ldr r0, [r0]
151 ; THUMB2-NEXT: ldr r0, [r0]
152 ; THUMB2-NEXT: str.w r0, [sp, #1028]
153 ; THUMB2-NEXT: add r0, sp, #4
154 ; THUMB2-NEXT: bl foo
155 ; THUMB2-NEXT: ldr.w r0, [sp, #1028]
156 ; THUMB2-NEXT: ldr r1, .LCPI0_1
157 ; THUMB2-NEXT: .LPC0_1:
158 ; THUMB2-NEXT: add r1, pc
159 ; THUMB2-NEXT: ldr r1, [r1]
160 ; THUMB2-NEXT: ldr r1, [r1]
161 ; THUMB2-NEXT: cmp r1, r0
162 ; THUMB2-NEXT: ittt eq
163 ; THUMB2-NEXT: moveq r0, #0
164 ; THUMB2-NEXT: addeq.w sp, sp, #1032
165 ; THUMB2-NEXT: popeq {r7, pc}
166 ; THUMB2-NEXT: .LBB0_1:
167 ; THUMB2-NEXT: bl __stack_chk_fail
168 ; THUMB2-NEXT: .p2align 2
169 ; THUMB2-NEXT: @ %bb.2:
170 ; THUMB2-NEXT: .LCPI0_0:
171 ; THUMB2-NEXT: .Ltmp0:
172 ; THUMB2-NEXT: .long __stack_chk_guard(GOT_PREL)-((.LPC0_0+4)-.Ltmp0)
173 ; THUMB2-NEXT: .LCPI0_1:
174 ; THUMB2-NEXT: .Ltmp1:
175 ; THUMB2-NEXT: .long __stack_chk_guard(GOT_PREL)-((.LPC0_1+4)-.Ltmp1)
177 ; THUMB2-PIC-LABEL: test1:
178 ; THUMB2-PIC: @ %bb.0:
179 ; THUMB2-PIC-NEXT: .save {r7, lr}
180 ; THUMB2-PIC-NEXT: push {r7, lr}
181 ; THUMB2-PIC-NEXT: .pad #1032
182 ; THUMB2-PIC-NEXT: sub.w sp, sp, #1032
183 ; THUMB2-PIC-NEXT: ldr r0, .LCPI0_0
184 ; THUMB2-PIC-NEXT: .LPC0_0:
185 ; THUMB2-PIC-NEXT: add r0, pc
186 ; THUMB2-PIC-NEXT: ldr r0, [r0]
187 ; THUMB2-PIC-NEXT: ldr r0, [r0]
188 ; THUMB2-PIC-NEXT: str.w r0, [sp, #1028]
189 ; THUMB2-PIC-NEXT: add r0, sp, #4
190 ; THUMB2-PIC-NEXT: bl foo
191 ; THUMB2-PIC-NEXT: ldr.w r0, [sp, #1028]
192 ; THUMB2-PIC-NEXT: ldr r1, .LCPI0_1
193 ; THUMB2-PIC-NEXT: .LPC0_1:
194 ; THUMB2-PIC-NEXT: add r1, pc
195 ; THUMB2-PIC-NEXT: ldr r1, [r1]
196 ; THUMB2-PIC-NEXT: ldr r1, [r1]
197 ; THUMB2-PIC-NEXT: cmp r1, r0
198 ; THUMB2-PIC-NEXT: ittt eq
199 ; THUMB2-PIC-NEXT: moveq r0, #0
200 ; THUMB2-PIC-NEXT: addeq.w sp, sp, #1032
201 ; THUMB2-PIC-NEXT: popeq {r7, pc}
202 ; THUMB2-PIC-NEXT: .LBB0_1:
203 ; THUMB2-PIC-NEXT: bl __stack_chk_fail
204 ; THUMB2-PIC-NEXT: .p2align 2
205 ; THUMB2-PIC-NEXT: @ %bb.2:
206 ; THUMB2-PIC-NEXT: .LCPI0_0:
207 ; THUMB2-PIC-NEXT: .Ltmp0:
208 ; THUMB2-PIC-NEXT: .long __stack_chk_guard(GOT_PREL)-((.LPC0_0+4)-.Ltmp0)
209 ; THUMB2-PIC-NEXT: .LCPI0_1:
210 ; THUMB2-PIC-NEXT: .Ltmp1:
211 ; THUMB2-PIC-NEXT: .long __stack_chk_guard(GOT_PREL)-((.LPC0_1+4)-.Ltmp1)
212 %a1 = alloca [256 x i32], align 4
213 call void @foo(ptr %a1) #3
217 declare void @foo(ptr)
219 attributes #0 = { nounwind sspstrong }
221 !llvm.module.flags = !{!0}
222 !0 = !{i32 8, !"PIC Level", i32 2}