comparison test/CodeGen/X86/stack-protector.ll @ 0:95c75e76d11b LLVM3.4

LLVM 3.4
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Thu, 12 Dec 2013 13:56:28 +0900
parents
children 54457678186b
comparison
equal deleted inserted replaced
-1:000000000000 0:95c75e76d11b
1 ; RUN: llc -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck --check-prefix=LINUX-I386 %s
2 ; RUN: llc -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck --check-prefix=LINUX-X64 %s
3 ; RUN: llc -code-model=kernel -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck --check-prefix=LINUX-KERNEL-X64 %s
4 ; RUN: llc -mtriple=x86_64-apple-darwin < %s -o - | FileCheck --check-prefix=DARWIN-X64 %s
5 ; RUN: llc -mtriple=amd64-pc-openbsd < %s -o - | FileCheck --check-prefix=OPENBSD-AMD64 %s
6
7 %struct.foo = type { [16 x i8] }
8 %struct.foo.0 = type { [4 x i8] }
9 %struct.pair = type { i32, i32 }
10 %struct.nest = type { %struct.pair, %struct.pair }
11 %struct.vec = type { <4 x i32> }
12 %class.A = type { [2 x i8] }
13 %struct.deep = type { %union.anon }
14 %union.anon = type { %struct.anon }
15 %struct.anon = type { %struct.anon.0 }
16 %struct.anon.0 = type { %union.anon.1 }
17 %union.anon.1 = type { [2 x i8] }
18 %struct.small = type { i8 }
19
20 @.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
21
22 ; test1a: array of [16 x i8]
23 ; no ssp attribute
24 ; Requires no protector.
25 define void @test1a(i8* %a) nounwind uwtable {
26 entry:
27 ; LINUX-I386-LABEL: test1a:
28 ; LINUX-I386-NOT: calll __stack_chk_fail
29 ; LINUX-I386: .cfi_endproc
30
31 ; LINUX-X64-LABEL: test1a:
32 ; LINUX-X64-NOT: callq __stack_chk_fail
33 ; LINUX-X64: .cfi_endproc
34
35 ; LINUX-KERNEL-X64-LABEL: test1a:
36 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
37 ; LINUX-KERNEL-X64: .cfi_endproc
38
39 ; DARWIN-X64-LABEL: test1a:
40 ; DARWIN-X64-NOT: callq ___stack_chk_fail
41 ; DARWIN-X64: .cfi_endproc
42 %a.addr = alloca i8*, align 8
43 %buf = alloca [16 x i8], align 16
44 store i8* %a, i8** %a.addr, align 8
45 %arraydecay = getelementptr inbounds [16 x i8]* %buf, i32 0, i32 0
46 %0 = load i8** %a.addr, align 8
47 %call = call i8* @strcpy(i8* %arraydecay, i8* %0)
48 %arraydecay1 = getelementptr inbounds [16 x i8]* %buf, i32 0, i32 0
49 %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %arraydecay1)
50 ret void
51 }
52
53 ; test1b: array of [16 x i8]
54 ; ssp attribute
55 ; Requires protector.
56 define void @test1b(i8* %a) nounwind uwtable ssp {
57 entry:
58 ; LINUX-I386-LABEL: test1b:
59 ; LINUX-I386: mov{{l|q}} %gs:
60 ; LINUX-I386: calll __stack_chk_fail
61
62 ; LINUX-X64-LABEL: test1b:
63 ; LINUX-X64: mov{{l|q}} %fs:
64 ; LINUX-X64: callq __stack_chk_fail
65
66 ; LINUX-KERNEL-X64-LABEL: test1b:
67 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
68 ; LINUX-KERNEL-X64: callq __stack_chk_fail
69
70 ; DARWIN-X64-LABEL: test1b:
71 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
72 ; DARWIN-X64: callq ___stack_chk_fail
73
74 ; OPENBSD-AMD64-LABEL: test1b:
75 ; OPENBSD-AMD64: movq __guard_local(%rip)
76 ; OPENBSD-AMD64: callq __stack_smash_handler
77 %a.addr = alloca i8*, align 8
78 %buf = alloca [16 x i8], align 16
79 store i8* %a, i8** %a.addr, align 8
80 %arraydecay = getelementptr inbounds [16 x i8]* %buf, i32 0, i32 0
81 %0 = load i8** %a.addr, align 8
82 %call = call i8* @strcpy(i8* %arraydecay, i8* %0)
83 %arraydecay1 = getelementptr inbounds [16 x i8]* %buf, i32 0, i32 0
84 %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %arraydecay1)
85 ret void
86 }
87
88 ; test1c: array of [16 x i8]
89 ; sspstrong attribute
90 ; Requires protector.
91 define void @test1c(i8* %a) nounwind uwtable sspstrong {
92 entry:
93 ; LINUX-I386-LABEL: test1c:
94 ; LINUX-I386: mov{{l|q}} %gs:
95 ; LINUX-I386: calll __stack_chk_fail
96
97 ; LINUX-X64-LABEL: test1c:
98 ; LINUX-X64: mov{{l|q}} %fs:
99 ; LINUX-X64: callq __stack_chk_fail
100
101 ; LINUX-KERNEL-X64-LABEL: test1c:
102 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
103 ; LINUX-KERNEL-X64: callq __stack_chk_fail
104
105 ; DARWIN-X64-LABEL: test1c:
106 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
107 ; DARWIN-X64: callq ___stack_chk_fail
108 %a.addr = alloca i8*, align 8
109 %buf = alloca [16 x i8], align 16
110 store i8* %a, i8** %a.addr, align 8
111 %arraydecay = getelementptr inbounds [16 x i8]* %buf, i32 0, i32 0
112 %0 = load i8** %a.addr, align 8
113 %call = call i8* @strcpy(i8* %arraydecay, i8* %0)
114 %arraydecay1 = getelementptr inbounds [16 x i8]* %buf, i32 0, i32 0
115 %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %arraydecay1)
116 ret void
117 }
118
119 ; test1d: array of [16 x i8]
120 ; sspreq attribute
121 ; Requires protector.
122 define void @test1d(i8* %a) nounwind uwtable sspreq {
123 entry:
124 ; LINUX-I386-LABEL: test1d:
125 ; LINUX-I386: mov{{l|q}} %gs:
126 ; LINUX-I386: calll __stack_chk_fail
127
128 ; LINUX-X64-LABEL: test1d:
129 ; LINUX-X64: mov{{l|q}} %fs:
130 ; LINUX-X64: callq __stack_chk_fail
131
132 ; LINUX-KERNEL-X64-LABEL: test1d:
133 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
134 ; LINUX-KERNEL-X64: callq __stack_chk_fail
135
136 ; DARWIN-X64-LABEL: test1d:
137 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
138 ; DARWIN-X64: callq ___stack_chk_fail
139 %a.addr = alloca i8*, align 8
140 %buf = alloca [16 x i8], align 16
141 store i8* %a, i8** %a.addr, align 8
142 %arraydecay = getelementptr inbounds [16 x i8]* %buf, i32 0, i32 0
143 %0 = load i8** %a.addr, align 8
144 %call = call i8* @strcpy(i8* %arraydecay, i8* %0)
145 %arraydecay1 = getelementptr inbounds [16 x i8]* %buf, i32 0, i32 0
146 %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %arraydecay1)
147 ret void
148 }
149
150 ; test2a: struct { [16 x i8] }
151 ; no ssp attribute
152 ; Requires no protector.
153 define void @test2a(i8* %a) nounwind uwtable {
154 entry:
155 ; LINUX-I386-LABEL: test2a:
156 ; LINUX-I386-NOT: calll __stack_chk_fail
157 ; LINUX-I386: .cfi_endproc
158
159 ; LINUX-X64-LABEL: test2a:
160 ; LINUX-X64-NOT: callq __stack_chk_fail
161 ; LINUX-X64: .cfi_endproc
162
163 ; LINUX-KERNEL-X64-LABEL: test2a:
164 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
165 ; LINUX-KERNEL-X64: .cfi_endproc
166
167 ; DARWIN-X64-LABEL: test2a:
168 ; DARWIN-X64-NOT: callq ___stack_chk_fail
169 ; DARWIN-X64: .cfi_endproc
170 %a.addr = alloca i8*, align 8
171 %b = alloca %struct.foo, align 1
172 store i8* %a, i8** %a.addr, align 8
173 %buf = getelementptr inbounds %struct.foo* %b, i32 0, i32 0
174 %arraydecay = getelementptr inbounds [16 x i8]* %buf, i32 0, i32 0
175 %0 = load i8** %a.addr, align 8
176 %call = call i8* @strcpy(i8* %arraydecay, i8* %0)
177 %buf1 = getelementptr inbounds %struct.foo* %b, i32 0, i32 0
178 %arraydecay2 = getelementptr inbounds [16 x i8]* %buf1, i32 0, i32 0
179 %call3 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %arraydecay2)
180 ret void
181 }
182
183 ; test2b: struct { [16 x i8] }
184 ; ssp attribute
185 ; Requires protector.
186 define void @test2b(i8* %a) nounwind uwtable ssp {
187 entry:
188 ; LINUX-I386-LABEL: test2b:
189 ; LINUX-I386: mov{{l|q}} %gs:
190 ; LINUX-I386: calll __stack_chk_fail
191
192 ; LINUX-X64-LABEL: test2b:
193 ; LINUX-X64: mov{{l|q}} %fs:
194 ; LINUX-X64: callq __stack_chk_fail
195
196 ; LINUX-KERNEL-X64-LABEL: test2b:
197 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
198 ; LINUX-KERNEL-X64: callq __stack_chk_fail
199
200 ; DARWIN-X64-LABEL: test2b:
201 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
202 ; DARWIN-X64: callq ___stack_chk_fail
203 %a.addr = alloca i8*, align 8
204 %b = alloca %struct.foo, align 1
205 store i8* %a, i8** %a.addr, align 8
206 %buf = getelementptr inbounds %struct.foo* %b, i32 0, i32 0
207 %arraydecay = getelementptr inbounds [16 x i8]* %buf, i32 0, i32 0
208 %0 = load i8** %a.addr, align 8
209 %call = call i8* @strcpy(i8* %arraydecay, i8* %0)
210 %buf1 = getelementptr inbounds %struct.foo* %b, i32 0, i32 0
211 %arraydecay2 = getelementptr inbounds [16 x i8]* %buf1, i32 0, i32 0
212 %call3 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %arraydecay2)
213 ret void
214 }
215
216 ; test2c: struct { [16 x i8] }
217 ; sspstrong attribute
218 ; Requires protector.
219 define void @test2c(i8* %a) nounwind uwtable sspstrong {
220 entry:
221 ; LINUX-I386-LABEL: test2c:
222 ; LINUX-I386: mov{{l|q}} %gs:
223 ; LINUX-I386: calll __stack_chk_fail
224
225 ; LINUX-X64-LABEL: test2c:
226 ; LINUX-X64: mov{{l|q}} %fs:
227 ; LINUX-X64: callq __stack_chk_fail
228
229 ; LINUX-KERNEL-X64-LABEL: test2c:
230 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
231 ; LINUX-KERNEL-X64: callq __stack_chk_fail
232
233 ; DARWIN-X64-LABEL: test2c:
234 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
235 ; DARWIN-X64: callq ___stack_chk_fail
236 %a.addr = alloca i8*, align 8
237 %b = alloca %struct.foo, align 1
238 store i8* %a, i8** %a.addr, align 8
239 %buf = getelementptr inbounds %struct.foo* %b, i32 0, i32 0
240 %arraydecay = getelementptr inbounds [16 x i8]* %buf, i32 0, i32 0
241 %0 = load i8** %a.addr, align 8
242 %call = call i8* @strcpy(i8* %arraydecay, i8* %0)
243 %buf1 = getelementptr inbounds %struct.foo* %b, i32 0, i32 0
244 %arraydecay2 = getelementptr inbounds [16 x i8]* %buf1, i32 0, i32 0
245 %call3 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %arraydecay2)
246 ret void
247 }
248
249 ; test2d: struct { [16 x i8] }
250 ; sspreq attribute
251 ; Requires protector.
252 define void @test2d(i8* %a) nounwind uwtable sspreq {
253 entry:
254 ; LINUX-I386-LABEL: test2d:
255 ; LINUX-I386: mov{{l|q}} %gs:
256 ; LINUX-I386: calll __stack_chk_fail
257
258 ; LINUX-X64-LABEL: test2d:
259 ; LINUX-X64: mov{{l|q}} %fs:
260 ; LINUX-X64: callq __stack_chk_fail
261
262 ; LINUX-KERNEL-X64-LABEL: test2d:
263 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
264 ; LINUX-KERNEL-X64: callq __stack_chk_fail
265
266 ; DARWIN-X64-LABEL: test2d:
267 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
268 ; DARWIN-X64: callq ___stack_chk_fail
269 %a.addr = alloca i8*, align 8
270 %b = alloca %struct.foo, align 1
271 store i8* %a, i8** %a.addr, align 8
272 %buf = getelementptr inbounds %struct.foo* %b, i32 0, i32 0
273 %arraydecay = getelementptr inbounds [16 x i8]* %buf, i32 0, i32 0
274 %0 = load i8** %a.addr, align 8
275 %call = call i8* @strcpy(i8* %arraydecay, i8* %0)
276 %buf1 = getelementptr inbounds %struct.foo* %b, i32 0, i32 0
277 %arraydecay2 = getelementptr inbounds [16 x i8]* %buf1, i32 0, i32 0
278 %call3 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %arraydecay2)
279 ret void
280 }
281
282 ; test3a: array of [4 x i8]
283 ; no ssp attribute
284 ; Requires no protector.
285 define void @test3a(i8* %a) nounwind uwtable {
286 entry:
287 ; LINUX-I386-LABEL: test3a:
288 ; LINUX-I386-NOT: calll __stack_chk_fail
289 ; LINUX-I386: .cfi_endproc
290
291 ; LINUX-X64-LABEL: test3a:
292 ; LINUX-X64-NOT: callq __stack_chk_fail
293 ; LINUX-X64: .cfi_endproc
294
295 ; LINUX-KERNEL-X64-LABEL: test3a:
296 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
297 ; LINUX-KERNEL-X64: .cfi_endproc
298
299 ; DARWIN-X64-LABEL: test3a:
300 ; DARWIN-X64-NOT: callq ___stack_chk_fail
301 ; DARWIN-X64: .cfi_endproc
302 %a.addr = alloca i8*, align 8
303 %buf = alloca [4 x i8], align 1
304 store i8* %a, i8** %a.addr, align 8
305 %arraydecay = getelementptr inbounds [4 x i8]* %buf, i32 0, i32 0
306 %0 = load i8** %a.addr, align 8
307 %call = call i8* @strcpy(i8* %arraydecay, i8* %0)
308 %arraydecay1 = getelementptr inbounds [4 x i8]* %buf, i32 0, i32 0
309 %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %arraydecay1)
310 ret void
311 }
312
313 ; test3b: array [4 x i8]
314 ; ssp attribute
315 ; Requires no protector.
316 define void @test3b(i8* %a) nounwind uwtable ssp {
317 entry:
318 ; LINUX-I386-LABEL: test3b:
319 ; LINUX-I386-NOT: calll __stack_chk_fail
320 ; LINUX-I386: .cfi_endproc
321
322 ; LINUX-X64-LABEL: test3b:
323 ; LINUX-X64-NOT: callq __stack_chk_fail
324 ; LINUX-X64: .cfi_endproc
325
326 ; LINUX-KERNEL-X64-LABEL: test3b:
327 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
328 ; LINUX-KERNEL-X64: .cfi_endproc
329
330 ; DARWIN-X64-LABEL: test3b:
331 ; DARWIN-X64-NOT: callq ___stack_chk_fail
332 ; DARWIN-X64: .cfi_endproc
333 %a.addr = alloca i8*, align 8
334 %buf = alloca [4 x i8], align 1
335 store i8* %a, i8** %a.addr, align 8
336 %arraydecay = getelementptr inbounds [4 x i8]* %buf, i32 0, i32 0
337 %0 = load i8** %a.addr, align 8
338 %call = call i8* @strcpy(i8* %arraydecay, i8* %0)
339 %arraydecay1 = getelementptr inbounds [4 x i8]* %buf, i32 0, i32 0
340 %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %arraydecay1)
341 ret void
342 }
343
344 ; test3c: array of [4 x i8]
345 ; sspstrong attribute
346 ; Requires protector.
347 define void @test3c(i8* %a) nounwind uwtable sspstrong {
348 entry:
349 ; LINUX-I386-LABEL: test3c:
350 ; LINUX-I386: mov{{l|q}} %gs:
351 ; LINUX-I386: calll __stack_chk_fail
352
353 ; LINUX-X64-LABEL: test3c:
354 ; LINUX-X64: mov{{l|q}} %fs:
355 ; LINUX-X64: callq __stack_chk_fail
356
357 ; LINUX-KERNEL-X64-LABEL: test3c:
358 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
359 ; LINUX-KERNEL-X64: callq __stack_chk_fail
360
361 ; DARWIN-X64-LABEL: test3c:
362 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
363 ; DARWIN-X64: callq ___stack_chk_fail
364 %a.addr = alloca i8*, align 8
365 %buf = alloca [4 x i8], align 1
366 store i8* %a, i8** %a.addr, align 8
367 %arraydecay = getelementptr inbounds [4 x i8]* %buf, i32 0, i32 0
368 %0 = load i8** %a.addr, align 8
369 %call = call i8* @strcpy(i8* %arraydecay, i8* %0)
370 %arraydecay1 = getelementptr inbounds [4 x i8]* %buf, i32 0, i32 0
371 %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %arraydecay1)
372 ret void
373 }
374
375 ; test3d: array of [4 x i8]
376 ; sspreq attribute
377 ; Requires protector.
378 define void @test3d(i8* %a) nounwind uwtable sspreq {
379 entry:
380 ; LINUX-I386-LABEL: test3d:
381 ; LINUX-I386: mov{{l|q}} %gs:
382 ; LINUX-I386: calll __stack_chk_fail
383
384 ; LINUX-X64-LABEL: test3d:
385 ; LINUX-X64: mov{{l|q}} %fs:
386 ; LINUX-X64: callq __stack_chk_fail
387
388 ; LINUX-KERNEL-X64-LABEL: test3d:
389 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
390 ; LINUX-KERNEL-X64: callq __stack_chk_fail
391
392 ; DARWIN-X64-LABEL: test3d:
393 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
394 ; DARWIN-X64: callq ___stack_chk_fail
395 %a.addr = alloca i8*, align 8
396 %buf = alloca [4 x i8], align 1
397 store i8* %a, i8** %a.addr, align 8
398 %arraydecay = getelementptr inbounds [4 x i8]* %buf, i32 0, i32 0
399 %0 = load i8** %a.addr, align 8
400 %call = call i8* @strcpy(i8* %arraydecay, i8* %0)
401 %arraydecay1 = getelementptr inbounds [4 x i8]* %buf, i32 0, i32 0
402 %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %arraydecay1)
403 ret void
404 }
405
406 ; test4a: struct { [4 x i8] }
407 ; no ssp attribute
408 ; Requires no protector.
409 define void @test4a(i8* %a) nounwind uwtable {
410 entry:
411 ; LINUX-I386-LABEL: test4a:
412 ; LINUX-I386-NOT: calll __stack_chk_fail
413 ; LINUX-I386: .cfi_endproc
414
415 ; LINUX-X64-LABEL: test4a:
416 ; LINUX-X64-NOT: callq __stack_chk_fail
417 ; LINUX-X64: .cfi_endproc
418
419 ; LINUX-KERNEL-X64-LABEL: test4a:
420 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
421 ; LINUX-KERNEL-X64: .cfi_endproc
422
423 ; DARWIN-X64-LABEL: test4a:
424 ; DARWIN-X64-NOT: callq ___stack_chk_fail
425 ; DARWIN-X64: .cfi_endproc
426 %a.addr = alloca i8*, align 8
427 %b = alloca %struct.foo.0, align 1
428 store i8* %a, i8** %a.addr, align 8
429 %buf = getelementptr inbounds %struct.foo.0* %b, i32 0, i32 0
430 %arraydecay = getelementptr inbounds [4 x i8]* %buf, i32 0, i32 0
431 %0 = load i8** %a.addr, align 8
432 %call = call i8* @strcpy(i8* %arraydecay, i8* %0)
433 %buf1 = getelementptr inbounds %struct.foo.0* %b, i32 0, i32 0
434 %arraydecay2 = getelementptr inbounds [4 x i8]* %buf1, i32 0, i32 0
435 %call3 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %arraydecay2)
436 ret void
437 }
438
439 ; test4b: struct { [4 x i8] }
440 ; ssp attribute
441 ; Requires no protector.
442 define void @test4b(i8* %a) nounwind uwtable ssp {
443 entry:
444 ; LINUX-I386-LABEL: test4b:
445 ; LINUX-I386-NOT: calll __stack_chk_fail
446 ; LINUX-I386: .cfi_endproc
447
448 ; LINUX-X64-LABEL: test4b:
449 ; LINUX-X64-NOT: callq __stack_chk_fail
450 ; LINUX-X64: .cfi_endproc
451
452 ; LINUX-KERNEL-X64-LABEL: test4b:
453 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
454 ; LINUX-KERNEL-X64: .cfi_endproc
455
456 ; DARWIN-X64-LABEL: test4b:
457 ; DARWIN-X64-NOT: callq ___stack_chk_fail
458 ; DARWIN-X64: .cfi_endproc
459 %a.addr = alloca i8*, align 8
460 %b = alloca %struct.foo.0, align 1
461 store i8* %a, i8** %a.addr, align 8
462 %buf = getelementptr inbounds %struct.foo.0* %b, i32 0, i32 0
463 %arraydecay = getelementptr inbounds [4 x i8]* %buf, i32 0, i32 0
464 %0 = load i8** %a.addr, align 8
465 %call = call i8* @strcpy(i8* %arraydecay, i8* %0)
466 %buf1 = getelementptr inbounds %struct.foo.0* %b, i32 0, i32 0
467 %arraydecay2 = getelementptr inbounds [4 x i8]* %buf1, i32 0, i32 0
468 %call3 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %arraydecay2)
469 ret void
470 }
471
472 ; test4c: struct { [4 x i8] }
473 ; sspstrong attribute
474 ; Requires protector.
475 define void @test4c(i8* %a) nounwind uwtable sspstrong {
476 entry:
477 ; LINUX-I386-LABEL: test4c:
478 ; LINUX-I386: mov{{l|q}} %gs:
479 ; LINUX-I386: calll __stack_chk_fail
480
481 ; LINUX-X64-LABEL: test4c:
482 ; LINUX-X64: mov{{l|q}} %fs:
483 ; LINUX-X64: callq __stack_chk_fail
484
485 ; LINUX-KERNEL-X64-LABEL: test4c:
486 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
487 ; LINUX-KERNEL-X64: callq __stack_chk_fail
488
489 ; DARWIN-X64-LABEL: test4c:
490 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
491 ; DARWIN-X64: callq ___stack_chk_fail
492 %a.addr = alloca i8*, align 8
493 %b = alloca %struct.foo.0, align 1
494 store i8* %a, i8** %a.addr, align 8
495 %buf = getelementptr inbounds %struct.foo.0* %b, i32 0, i32 0
496 %arraydecay = getelementptr inbounds [4 x i8]* %buf, i32 0, i32 0
497 %0 = load i8** %a.addr, align 8
498 %call = call i8* @strcpy(i8* %arraydecay, i8* %0)
499 %buf1 = getelementptr inbounds %struct.foo.0* %b, i32 0, i32 0
500 %arraydecay2 = getelementptr inbounds [4 x i8]* %buf1, i32 0, i32 0
501 %call3 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %arraydecay2)
502 ret void
503 }
504
505 ; test4d: struct { [4 x i8] }
506 ; sspreq attribute
507 ; Requires protector.
508 define void @test4d(i8* %a) nounwind uwtable sspreq {
509 entry:
510 ; LINUX-I386-LABEL: test4d:
511 ; LINUX-I386: mov{{l|q}} %gs:
512 ; LINUX-I386: calll __stack_chk_fail
513
514 ; LINUX-X64-LABEL: test4d:
515 ; LINUX-X64: mov{{l|q}} %fs:
516 ; LINUX-X64: callq __stack_chk_fail
517
518 ; LINUX-KERNEL-X64-LABEL: test4d:
519 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
520 ; LINUX-KERNEL-X64: callq __stack_chk_fail
521
522 ; DARWIN-X64-LABEL: test4d:
523 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
524 ; DARWIN-X64: callq ___stack_chk_fail
525 %a.addr = alloca i8*, align 8
526 %b = alloca %struct.foo.0, align 1
527 store i8* %a, i8** %a.addr, align 8
528 %buf = getelementptr inbounds %struct.foo.0* %b, i32 0, i32 0
529 %arraydecay = getelementptr inbounds [4 x i8]* %buf, i32 0, i32 0
530 %0 = load i8** %a.addr, align 8
531 %call = call i8* @strcpy(i8* %arraydecay, i8* %0)
532 %buf1 = getelementptr inbounds %struct.foo.0* %b, i32 0, i32 0
533 %arraydecay2 = getelementptr inbounds [4 x i8]* %buf1, i32 0, i32 0
534 %call3 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %arraydecay2)
535 ret void
536 }
537
538 ; test5a: no arrays / no nested arrays
539 ; no ssp attribute
540 ; Requires no protector.
541 define void @test5a(i8* %a) nounwind uwtable {
542 entry:
543 ; LINUX-I386-LABEL: test5a:
544 ; LINUX-I386-NOT: calll __stack_chk_fail
545 ; LINUX-I386: .cfi_endproc
546
547 ; LINUX-X64-LABEL: test5a:
548 ; LINUX-X64-NOT: callq __stack_chk_fail
549 ; LINUX-X64: .cfi_endproc
550
551 ; LINUX-KERNEL-X64-LABEL: test5a:
552 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
553 ; LINUX-KERNEL-X64: .cfi_endproc
554
555 ; DARWIN-X64-LABEL: test5a:
556 ; DARWIN-X64-NOT: callq ___stack_chk_fail
557 ; DARWIN-X64: .cfi_endproc
558 %a.addr = alloca i8*, align 8
559 store i8* %a, i8** %a.addr, align 8
560 %0 = load i8** %a.addr, align 8
561 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %0)
562 ret void
563 }
564
565 ; test5b: no arrays / no nested arrays
566 ; ssp attribute
567 ; Requires no protector.
568 define void @test5b(i8* %a) nounwind uwtable ssp {
569 entry:
570 ; LINUX-I386-LABEL: test5b:
571 ; LINUX-I386-NOT: calll __stack_chk_fail
572 ; LINUX-I386: .cfi_endproc
573
574 ; LINUX-X64-LABEL: test5b:
575 ; LINUX-X64-NOT: callq __stack_chk_fail
576 ; LINUX-X64: .cfi_endproc
577
578 ; LINUX-KERNEL-X64-LABEL: test5b:
579 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
580 ; LINUX-KERNEL-X64: .cfi_endproc
581
582 ; DARWIN-X64-LABEL: test5b:
583 ; DARWIN-X64-NOT: callq ___stack_chk_fail
584 ; DARWIN-X64: .cfi_endproc
585 %a.addr = alloca i8*, align 8
586 store i8* %a, i8** %a.addr, align 8
587 %0 = load i8** %a.addr, align 8
588 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %0)
589 ret void
590 }
591
592 ; test5c: no arrays / no nested arrays
593 ; sspstrong attribute
594 ; Requires no protector.
595 define void @test5c(i8* %a) nounwind uwtable sspstrong {
596 entry:
597 ; LINUX-I386-LABEL: test5c:
598 ; LINUX-I386-NOT: calll __stack_chk_fail
599 ; LINUX-I386: .cfi_endproc
600
601 ; LINUX-X64-LABEL: test5c:
602 ; LINUX-X64-NOT: callq __stack_chk_fail
603 ; LINUX-X64: .cfi_endproc
604
605 ; LINUX-KERNEL-X64-LABEL: test5c:
606 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
607 ; LINUX-KERNEL-X64: .cfi_endproc
608
609 ; DARWIN-X64-LABEL: test5c:
610 ; DARWIN-X64-NOT: callq ___stack_chk_fail
611 ; DARWIN-X64: .cfi_endproc
612 %a.addr = alloca i8*, align 8
613 store i8* %a, i8** %a.addr, align 8
614 %0 = load i8** %a.addr, align 8
615 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %0)
616 ret void
617 }
618
619 ; test5d: no arrays / no nested arrays
620 ; sspreq attribute
621 ; Requires protector.
622 define void @test5d(i8* %a) nounwind uwtable sspreq {
623 entry:
624 ; LINUX-I386-LABEL: test5d:
625 ; LINUX-I386: mov{{l|q}} %gs:
626 ; LINUX-I386: calll __stack_chk_fail
627
628 ; LINUX-X64-LABEL: test5d:
629 ; LINUX-X64: mov{{l|q}} %fs:
630 ; LINUX-X64: callq __stack_chk_fail
631
632 ; LINUX-KERNEL-X64-LABEL: test5d:
633 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
634 ; LINUX-KERNEL-X64: callq __stack_chk_fail
635
636 ; DARWIN-X64-LABEL: test5d:
637 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
638 ; DARWIN-X64: callq ___stack_chk_fail
639 %a.addr = alloca i8*, align 8
640 store i8* %a, i8** %a.addr, align 8
641 %0 = load i8** %a.addr, align 8
642 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* %0)
643 ret void
644 }
645
646 ; test6a: Address-of local taken (j = &a)
647 ; no ssp attribute
648 ; Requires no protector.
649 define void @test6a() nounwind uwtable {
650 entry:
651 ; LINUX-I386-LABEL: test6a:
652 ; LINUX-I386-NOT: calll __stack_chk_fail
653 ; LINUX-I386: .cfi_endproc
654
655 ; LINUX-X64-LABEL: test6a:
656 ; LINUX-X64-NOT: callq __stack_chk_fail
657 ; LINUX-X64: .cfi_endproc
658
659 ; LINUX-KERNEL-X64-LABEL: test6a:
660 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
661 ; LINUX-KERNEL-X64: .cfi_endproc
662
663 ; DARWIN-X64-LABEL: test6a:
664 ; DARWIN-X64-NOT: callq ___stack_chk_fail
665 ; DARWIN-X64: .cfi_endproc
666 %retval = alloca i32, align 4
667 %a = alloca i32, align 4
668 %j = alloca i32*, align 8
669 store i32 0, i32* %retval
670 %0 = load i32* %a, align 4
671 %add = add nsw i32 %0, 1
672 store i32 %add, i32* %a, align 4
673 store i32* %a, i32** %j, align 8
674 ret void
675 }
676
677 ; test6b: Address-of local taken (j = &a)
678 ; ssp attribute
679 ; Requires no protector.
680 define void @test6b() nounwind uwtable ssp {
681 entry:
682 ; LINUX-I386-LABEL: test6b:
683 ; LINUX-I386-NOT: calll __stack_chk_fail
684 ; LINUX-I386: .cfi_endproc
685
686 ; LINUX-X64-LABEL: test6b:
687 ; LINUX-X64-NOT: callq __stack_chk_fail
688 ; LINUX-X64: .cfi_endproc
689
690 ; LINUX-KERNEL-X64-LABEL: test6b:
691 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
692 ; LINUX-KERNEL-X64: .cfi_endproc
693
694 ; DARWIN-X64-LABEL: test6b:
695 ; DARWIN-X64-NOT: callq ___stack_chk_fail
696 ; DARWIN-X64: .cfi_endproc
697 %retval = alloca i32, align 4
698 %a = alloca i32, align 4
699 %j = alloca i32*, align 8
700 store i32 0, i32* %retval
701 %0 = load i32* %a, align 4
702 %add = add nsw i32 %0, 1
703 store i32 %add, i32* %a, align 4
704 store i32* %a, i32** %j, align 8
705 ret void
706 }
707
708 ; test6c: Address-of local taken (j = &a)
709 ; sspstrong attribute
710 ; Requires protector.
711 define void @test6c() nounwind uwtable sspstrong {
712 entry:
713 ; LINUX-I386-LABEL: test6c:
714 ; LINUX-I386: mov{{l|q}} %gs:
715 ; LINUX-I386: calll __stack_chk_fail
716
717 ; LINUX-X64-LABEL: test6c:
718 ; LINUX-X64: mov{{l|q}} %fs:
719 ; LINUX-X64: callq __stack_chk_fail
720
721 ; LINUX-KERNEL-X64-LABEL: test6c:
722 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
723 ; LINUX-KERNEL-X64: callq __stack_chk_fail
724
725 ; DARWIN-X64-LABEL: test6c:
726 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
727 ; DARWIN-X64: callq ___stack_chk_fail
728 %retval = alloca i32, align 4
729 %a = alloca i32, align 4
730 %j = alloca i32*, align 8
731 store i32 0, i32* %retval
732 %0 = load i32* %a, align 4
733 %add = add nsw i32 %0, 1
734 store i32 %add, i32* %a, align 4
735 store i32* %a, i32** %j, align 8
736 ret void
737 }
738
739 ; test6d: Address-of local taken (j = &a)
740 ; sspreq attribute
741 ; Requires protector.
742 define void @test6d() nounwind uwtable sspreq {
743 entry:
744 ; LINUX-I386-LABEL: test6d:
745 ; LINUX-I386: mov{{l|q}} %gs:
746 ; LINUX-I386: calll __stack_chk_fail
747
748 ; LINUX-X64-LABEL: test6d:
749 ; LINUX-X64: mov{{l|q}} %fs:
750 ; LINUX-X64: callq __stack_chk_fail
751
752 ; LINUX-KERNEL-X64-LABEL: test6d:
753 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
754 ; LINUX-KERNEL-X64: callq __stack_chk_fail
755
756 ; DARWIN-X64-LABEL: test6d:
757 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
758 ; DARWIN-X64: callq ___stack_chk_fail
759 %retval = alloca i32, align 4
760 %a = alloca i32, align 4
761 %j = alloca i32*, align 8
762 store i32 0, i32* %retval
763 %0 = load i32* %a, align 4
764 %add = add nsw i32 %0, 1
765 store i32 %add, i32* %a, align 4
766 store i32* %a, i32** %j, align 8
767 ret void
768 }
769
770 ; test7a: PtrToInt Cast
771 ; no ssp attribute
772 ; Requires no protector.
773 define void @test7a() nounwind uwtable readnone {
774 entry:
775 ; LINUX-I386-LABEL: test7a:
776 ; LINUX-I386-NOT: calll __stack_chk_fail
777 ; LINUX-I386: .cfi_endproc
778
779 ; LINUX-X64-LABEL: test7a:
780 ; LINUX-X64-NOT: callq __stack_chk_fail
781 ; LINUX-X64: .cfi_endproc
782
783 ; LINUX-KERNEL-X64-LABEL: test7a:
784 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
785 ; LINUX-KERNEL-X64: .cfi_endproc
786
787 ; DARWIN-X64-LABEL: test7a:
788 ; DARWIN-X64-NOT: callq ___stack_chk_fail
789 ; DARWIN-X64: .cfi_endproc
790 %a = alloca i32, align 4
791 %0 = ptrtoint i32* %a to i64
792 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i64 %0)
793 ret void
794 }
795
796 ; test7b: PtrToInt Cast
797 ; ssp attribute
798 ; Requires no protector.
799 define void @test7b() nounwind uwtable readnone ssp {
800 entry:
801 ; LINUX-I386-LABEL: test7b:
802 ; LINUX-I386-NOT: calll __stack_chk_fail
803 ; LINUX-I386: .cfi_endproc
804
805 ; LINUX-X64-LABEL: test7b:
806 ; LINUX-X64-NOT: callq __stack_chk_fail
807 ; LINUX-X64: .cfi_endproc
808
809 ; LINUX-KERNEL-X64-LABEL: test7b:
810 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
811 ; LINUX-KERNEL-X64: .cfi_endproc
812
813 ; DARWIN-X64-LABEL: test7b:
814 ; DARWIN-X64-NOT: callq ___stack_chk_fail
815 ; DARWIN-X64: .cfi_endproc
816 %a = alloca i32, align 4
817 %0 = ptrtoint i32* %a to i64
818 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i64 %0)
819 ret void
820 }
821
822 ; test7c: PtrToInt Cast
823 ; sspstrong attribute
824 ; Requires protector.
825 define void @test7c() nounwind uwtable readnone sspstrong {
826 entry:
827 ; LINUX-I386-LABEL: test7c:
828 ; LINUX-I386: mov{{l|q}} %gs:
829 ; LINUX-I386: calll __stack_chk_fail
830
831 ; LINUX-X64-LABEL: test7c:
832 ; LINUX-X64: mov{{l|q}} %fs:
833 ; LINUX-X64: callq __stack_chk_fail
834
835 ; LINUX-KERNEL-X64-LABEL: test7c:
836 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
837 ; LINUX-KERNEL-X64: callq __stack_chk_fail
838
839 ; DARWIN-X64-LABEL: test7c:
840 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
841 ; DARWIN-X64: callq ___stack_chk_fail
842 %a = alloca i32, align 4
843 %0 = ptrtoint i32* %a to i64
844 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i64 %0)
845 ret void
846 }
847
848 ; test7d: PtrToInt Cast
849 ; sspreq attribute
850 ; Requires protector.
851 define void @test7d() nounwind uwtable readnone sspreq {
852 entry:
853 ; LINUX-I386-LABEL: test7d:
854 ; LINUX-I386: mov{{l|q}} %gs:
855 ; LINUX-I386: calll __stack_chk_fail
856
857 ; LINUX-X64-LABEL: test7d:
858 ; LINUX-X64: mov{{l|q}} %fs:
859 ; LINUX-X64: callq __stack_chk_fail
860
861 ; LINUX-KERNEL-X64-LABEL: test7d:
862 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
863 ; LINUX-KERNEL-X64: callq __stack_chk_fail
864
865 ; DARWIN-X64-LABEL: test7d:
866 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
867 ; DARWIN-X64: callq ___stack_chk_fail
868 %a = alloca i32, align 4
869 %0 = ptrtoint i32* %a to i64
870 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i64 %0)
871 ret void
872 }
873
874 ; test8a: Passing addr-of to function call
875 ; no ssp attribute
876 ; Requires no protector.
877 define void @test8a() nounwind uwtable {
878 entry:
879 ; LINUX-I386-LABEL: test8a:
880 ; LINUX-I386-NOT: calll __stack_chk_fail
881 ; LINUX-I386: .cfi_endproc
882
883 ; LINUX-X64-LABEL: test8a:
884 ; LINUX-X64-NOT: callq __stack_chk_fail
885 ; LINUX-X64: .cfi_endproc
886
887 ; LINUX-KERNEL-X64-LABEL: test8a:
888 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
889 ; LINUX-KERNEL-X64: .cfi_endproc
890
891 ; DARWIN-X64-LABEL: test8a:
892 ; DARWIN-X64-NOT: callq ___stack_chk_fail
893 ; DARWIN-X64: .cfi_endproc
894 %b = alloca i32, align 4
895 call void @funcall(i32* %b) nounwind
896 ret void
897 }
898
899 ; test8b: Passing addr-of to function call
900 ; ssp attribute
901 ; Requires no protector.
902 define void @test8b() nounwind uwtable ssp {
903 entry:
904 ; LINUX-I386-LABEL: test8b:
905 ; LINUX-I386-NOT: calll __stack_chk_fail
906 ; LINUX-I386: .cfi_endproc
907
908 ; LINUX-X64-LABEL: test8b:
909 ; LINUX-X64-NOT: callq __stack_chk_fail
910 ; LINUX-X64: .cfi_endproc
911
912 ; LINUX-KERNEL-X64-LABEL: test8b:
913 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
914 ; LINUX-KERNEL-X64: .cfi_endproc
915
916 ; DARWIN-X64-LABEL: test8b:
917 ; DARWIN-X64-NOT: callq ___stack_chk_fail
918 ; DARWIN-X64: .cfi_endproc
919 %b = alloca i32, align 4
920 call void @funcall(i32* %b) nounwind
921 ret void
922 }
923
924 ; test8c: Passing addr-of to function call
925 ; sspstrong attribute
926 ; Requires protector.
927 define void @test8c() nounwind uwtable sspstrong {
928 entry:
929 ; LINUX-I386-LABEL: test8c:
930 ; LINUX-I386: mov{{l|q}} %gs:
931 ; LINUX-I386: calll __stack_chk_fail
932
933 ; LINUX-X64-LABEL: test8c:
934 ; LINUX-X64: mov{{l|q}} %fs:
935 ; LINUX-X64: callq __stack_chk_fail
936
937 ; LINUX-KERNEL-X64-LABEL: test8c:
938 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
939 ; LINUX-KERNEL-X64: callq __stack_chk_fail
940
941 ; DARWIN-X64-LABEL: test8c:
942 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
943 ; DARWIN-X64: callq ___stack_chk_fail
944 %b = alloca i32, align 4
945 call void @funcall(i32* %b) nounwind
946 ret void
947 }
948
949 ; test8d: Passing addr-of to function call
950 ; sspreq attribute
951 ; Requires protector.
952 define void @test8d() nounwind uwtable sspreq {
953 entry:
954 ; LINUX-I386-LABEL: test8d:
955 ; LINUX-I386: mov{{l|q}} %gs:
956 ; LINUX-I386: calll __stack_chk_fail
957
958 ; LINUX-X64-LABEL: test8d:
959 ; LINUX-X64: mov{{l|q}} %fs:
960 ; LINUX-X64: callq __stack_chk_fail
961
962 ; LINUX-KERNEL-X64-LABEL: test8d:
963 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
964 ; LINUX-KERNEL-X64: callq __stack_chk_fail
965
966 ; DARWIN-X64-LABEL: test8d:
967 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
968 ; DARWIN-X64: callq ___stack_chk_fail
969 %b = alloca i32, align 4
970 call void @funcall(i32* %b) nounwind
971 ret void
972 }
973
974 ; test9a: Addr-of in select instruction
975 ; no ssp attribute
976 ; Requires no protector.
977 define void @test9a() nounwind uwtable {
978 entry:
979 ; LINUX-I386-LABEL: test9a:
980 ; LINUX-I386-NOT: calll __stack_chk_fail
981 ; LINUX-I386: .cfi_endproc
982
983 ; LINUX-X64-LABEL: test9a:
984 ; LINUX-X64-NOT: callq __stack_chk_fail
985 ; LINUX-X64: .cfi_endproc
986
987 ; LINUX-KERNEL-X64-LABEL: test9a:
988 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
989 ; LINUX-KERNEL-X64: .cfi_endproc
990
991 ; DARWIN-X64-LABEL: test9a:
992 ; DARWIN-X64-NOT: callq ___stack_chk_fail
993 ; DARWIN-X64: .cfi_endproc
994 %x = alloca double, align 8
995 %call = call double @testi_aux() nounwind
996 store double %call, double* %x, align 8
997 %cmp2 = fcmp ogt double %call, 0.000000e+00
998 %y.1 = select i1 %cmp2, double* %x, double* null
999 %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), double* %y.1)
1000 ret void
1001 }
1002
1003 ; test9b: Addr-of in select instruction
1004 ; ssp attribute
1005 ; Requires no protector.
1006 define void @test9b() nounwind uwtable ssp {
1007 entry:
1008 ; LINUX-I386-LABEL: test9b:
1009 ; LINUX-I386-NOT: calll __stack_chk_fail
1010 ; LINUX-I386: .cfi_endproc
1011
1012 ; LINUX-X64-LABEL: test9b:
1013 ; LINUX-X64-NOT: callq __stack_chk_fail
1014 ; LINUX-X64: .cfi_endproc
1015
1016 ; LINUX-KERNEL-X64-LABEL: test9b:
1017 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1018 ; LINUX-KERNEL-X64: .cfi_endproc
1019
1020 ; DARWIN-X64-LABEL: test9b:
1021 ; DARWIN-X64-NOT: callq ___stack_chk_fail
1022 ; DARWIN-X64: .cfi_endproc
1023 %x = alloca double, align 8
1024 %call = call double @testi_aux() nounwind
1025 store double %call, double* %x, align 8
1026 %cmp2 = fcmp ogt double %call, 0.000000e+00
1027 %y.1 = select i1 %cmp2, double* %x, double* null
1028 %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), double* %y.1)
1029 ret void
1030 }
1031
1032 ; test9c: Addr-of in select instruction
1033 ; sspstrong attribute
1034 ; Requires protector.
1035 define void @test9c() nounwind uwtable sspstrong {
1036 entry:
1037 ; LINUX-I386-LABEL: test9c:
1038 ; LINUX-I386: mov{{l|q}} %gs:
1039 ; LINUX-I386: calll __stack_chk_fail
1040
1041 ; LINUX-X64-LABEL: test9c:
1042 ; LINUX-X64: mov{{l|q}} %fs:
1043 ; LINUX-X64: callq __stack_chk_fail
1044
1045 ; LINUX-KERNEL-X64-LABEL: test9c:
1046 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1047 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1048
1049 ; DARWIN-X64-LABEL: test9c:
1050 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
1051 ; DARWIN-X64: callq ___stack_chk_fail
1052 %x = alloca double, align 8
1053 %call = call double @testi_aux() nounwind
1054 store double %call, double* %x, align 8
1055 %cmp2 = fcmp ogt double %call, 0.000000e+00
1056 %y.1 = select i1 %cmp2, double* %x, double* null
1057 %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), double* %y.1)
1058 ret void
1059 }
1060
1061 ; test9d: Addr-of in select instruction
1062 ; sspreq attribute
1063 ; Requires protector.
1064 define void @test9d() nounwind uwtable sspreq {
1065 entry:
1066 ; LINUX-I386-LABEL: test9d:
1067 ; LINUX-I386: mov{{l|q}} %gs:
1068 ; LINUX-I386: calll __stack_chk_fail
1069
1070 ; LINUX-X64-LABEL: test9d:
1071 ; LINUX-X64: mov{{l|q}} %fs:
1072 ; LINUX-X64: callq __stack_chk_fail
1073
1074 ; LINUX-KERNEL-X64-LABEL: test9d:
1075 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1076 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1077
1078 ; DARWIN-X64-LABEL: test9d:
1079 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
1080 ; DARWIN-X64: callq ___stack_chk_fail
1081 %x = alloca double, align 8
1082 %call = call double @testi_aux() nounwind
1083 store double %call, double* %x, align 8
1084 %cmp2 = fcmp ogt double %call, 0.000000e+00
1085 %y.1 = select i1 %cmp2, double* %x, double* null
1086 %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), double* %y.1)
1087 ret void
1088 }
1089
1090 ; test10a: Addr-of in phi instruction
1091 ; no ssp attribute
1092 ; Requires no protector.
1093 define void @test10a() nounwind uwtable {
1094 entry:
1095 ; LINUX-I386-LABEL: test10a:
1096 ; LINUX-I386-NOT: calll __stack_chk_fail
1097 ; LINUX-I386: .cfi_endproc
1098
1099 ; LINUX-X64-LABEL: test10a:
1100 ; LINUX-X64-NOT: callq __stack_chk_fail
1101 ; LINUX-X64: .cfi_endproc
1102
1103 ; LINUX-KERNEL-X64-LABEL: test10a:
1104 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1105 ; LINUX-KERNEL-X64: .cfi_endproc
1106
1107 ; DARWIN-X64-LABEL: test10a:
1108 ; DARWIN-X64-NOT: callq ___stack_chk_fail
1109 ; DARWIN-X64: .cfi_endproc
1110 %x = alloca double, align 8
1111 %call = call double @testi_aux() nounwind
1112 store double %call, double* %x, align 8
1113 %cmp = fcmp ogt double %call, 3.140000e+00
1114 br i1 %cmp, label %if.then, label %if.else
1115
1116 if.then: ; preds = %entry
1117 %call1 = call double @testi_aux() nounwind
1118 store double %call1, double* %x, align 8
1119 br label %if.end4
1120
1121 if.else: ; preds = %entry
1122 %cmp2 = fcmp ogt double %call, 1.000000e+00
1123 br i1 %cmp2, label %if.then3, label %if.end4
1124
1125 if.then3: ; preds = %if.else
1126 br label %if.end4
1127
1128 if.end4: ; preds = %if.else, %if.then3, %if.then
1129 %y.0 = phi double* [ null, %if.then ], [ %x, %if.then3 ], [ null, %if.else ]
1130 %call5 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), double* %y.0) nounwind
1131 ret void
1132 }
1133
1134 ; test10b: Addr-of in phi instruction
1135 ; ssp attribute
1136 ; Requires no protector.
1137 define void @test10b() nounwind uwtable ssp {
1138 entry:
1139 ; LINUX-I386-LABEL: test10b:
1140 ; LINUX-I386-NOT: calll __stack_chk_fail
1141 ; LINUX-I386: .cfi_endproc
1142
1143 ; LINUX-X64-LABEL: test10b:
1144 ; LINUX-X64-NOT: callq __stack_chk_fail
1145 ; LINUX-X64: .cfi_endproc
1146
1147 ; LINUX-KERNEL-X64-LABEL: test10b:
1148 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1149 ; LINUX-KERNEL-X64: .cfi_endproc
1150
1151 ; DARWIN-X64-LABEL: test10b:
1152 ; DARWIN-X64-NOT: callq ___stack_chk_fail
1153 ; DARWIN-X64: .cfi_endproc
1154 %x = alloca double, align 8
1155 %call = call double @testi_aux() nounwind
1156 store double %call, double* %x, align 8
1157 %cmp = fcmp ogt double %call, 3.140000e+00
1158 br i1 %cmp, label %if.then, label %if.else
1159
1160 if.then: ; preds = %entry
1161 %call1 = call double @testi_aux() nounwind
1162 store double %call1, double* %x, align 8
1163 br label %if.end4
1164
1165 if.else: ; preds = %entry
1166 %cmp2 = fcmp ogt double %call, 1.000000e+00
1167 br i1 %cmp2, label %if.then3, label %if.end4
1168
1169 if.then3: ; preds = %if.else
1170 br label %if.end4
1171
1172 if.end4: ; preds = %if.else, %if.then3, %if.then
1173 %y.0 = phi double* [ null, %if.then ], [ %x, %if.then3 ], [ null, %if.else ]
1174 %call5 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), double* %y.0) nounwind
1175 ret void
1176 }
1177
1178 ; test10c: Addr-of in phi instruction
1179 ; sspstrong attribute
1180 ; Requires protector.
1181 define void @test10c() nounwind uwtable sspstrong {
1182 entry:
1183 ; LINUX-I386-LABEL: test10c:
1184 ; LINUX-I386: mov{{l|q}} %gs:
1185 ; LINUX-I386: calll __stack_chk_fail
1186
1187 ; LINUX-X64-LABEL: test10c:
1188 ; LINUX-X64: mov{{l|q}} %fs:
1189 ; LINUX-X64: callq __stack_chk_fail
1190
1191 ; LINUX-KERNEL-X64-LABEL: test10c:
1192 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1193 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1194
1195 ; DARWIN-X64-LABEL: test10c:
1196 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
1197 ; DARWIN-X64: callq ___stack_chk_fail
1198 %x = alloca double, align 8
1199 %call = call double @testi_aux() nounwind
1200 store double %call, double* %x, align 8
1201 %cmp = fcmp ogt double %call, 3.140000e+00
1202 br i1 %cmp, label %if.then, label %if.else
1203
1204 if.then: ; preds = %entry
1205 %call1 = call double @testi_aux() nounwind
1206 store double %call1, double* %x, align 8
1207 br label %if.end4
1208
1209 if.else: ; preds = %entry
1210 %cmp2 = fcmp ogt double %call, 1.000000e+00
1211 br i1 %cmp2, label %if.then3, label %if.end4
1212
1213 if.then3: ; preds = %if.else
1214 br label %if.end4
1215
1216 if.end4: ; preds = %if.else, %if.then3, %if.then
1217 %y.0 = phi double* [ null, %if.then ], [ %x, %if.then3 ], [ null, %if.else ]
1218 %call5 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), double* %y.0) nounwind
1219 ret void
1220 }
1221
1222 ; test10d: Addr-of in phi instruction
1223 ; sspreq attribute
1224 ; Requires protector.
1225 define void @test10d() nounwind uwtable sspreq {
1226 entry:
1227 ; LINUX-I386-LABEL: test10d:
1228 ; LINUX-I386: mov{{l|q}} %gs:
1229 ; LINUX-I386: calll __stack_chk_fail
1230
1231 ; LINUX-X64-LABEL: test10d:
1232 ; LINUX-X64: mov{{l|q}} %fs:
1233 ; LINUX-X64: callq __stack_chk_fail
1234
1235 ; LINUX-KERNEL-X64-LABEL: test10d:
1236 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1237 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1238
1239 ; DARWIN-X64-LABEL: test10d:
1240 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
1241 ; DARWIN-X64: callq ___stack_chk_fail
1242 %x = alloca double, align 8
1243 %call = call double @testi_aux() nounwind
1244 store double %call, double* %x, align 8
1245 %cmp = fcmp ogt double %call, 3.140000e+00
1246 br i1 %cmp, label %if.then, label %if.else
1247
1248 if.then: ; preds = %entry
1249 %call1 = call double @testi_aux() nounwind
1250 store double %call1, double* %x, align 8
1251 br label %if.end4
1252
1253 if.else: ; preds = %entry
1254 %cmp2 = fcmp ogt double %call, 1.000000e+00
1255 br i1 %cmp2, label %if.then3, label %if.end4
1256
1257 if.then3: ; preds = %if.else
1258 br label %if.end4
1259
1260 if.end4: ; preds = %if.else, %if.then3, %if.then
1261 %y.0 = phi double* [ null, %if.then ], [ %x, %if.then3 ], [ null, %if.else ]
1262 %call5 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), double* %y.0) nounwind
1263 ret void
1264 }
1265
1266 ; test11a: Addr-of struct element. (GEP followed by store).
1267 ; no ssp attribute
1268 ; Requires no protector.
1269 define void @test11a() nounwind uwtable {
1270 entry:
1271 ; LINUX-I386-LABEL: test11a:
1272 ; LINUX-I386-NOT: calll __stack_chk_fail
1273 ; LINUX-I386: .cfi_endproc
1274
1275 ; LINUX-X64-LABEL: test11a:
1276 ; LINUX-X64-NOT: callq __stack_chk_fail
1277 ; LINUX-X64: .cfi_endproc
1278
1279 ; LINUX-KERNEL-X64-LABEL: test11a:
1280 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1281 ; LINUX-KERNEL-X64: .cfi_endproc
1282
1283 ; DARWIN-X64-LABEL: test11a:
1284 ; DARWIN-X64-NOT: callq ___stack_chk_fail
1285 ; DARWIN-X64: .cfi_endproc
1286 %c = alloca %struct.pair, align 4
1287 %b = alloca i32*, align 8
1288 %y = getelementptr inbounds %struct.pair* %c, i32 0, i32 1
1289 store i32* %y, i32** %b, align 8
1290 %0 = load i32** %b, align 8
1291 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i32* %0)
1292 ret void
1293 }
1294
1295 ; test11b: Addr-of struct element. (GEP followed by store).
1296 ; ssp attribute
1297 ; Requires no protector.
1298 define void @test11b() nounwind uwtable ssp {
1299 entry:
1300 ; LINUX-I386-LABEL: test11b:
1301 ; LINUX-I386-NOT: calll __stack_chk_fail
1302 ; LINUX-I386: .cfi_endproc
1303
1304 ; LINUX-X64-LABEL: test11b:
1305 ; LINUX-X64-NOT: callq __stack_chk_fail
1306 ; LINUX-X64: .cfi_endproc
1307
1308 ; LINUX-KERNEL-X64-LABEL: test11b:
1309 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1310 ; LINUX-KERNEL-X64: .cfi_endproc
1311
1312 ; DARWIN-X64-LABEL: test11b:
1313 ; DARWIN-X64-NOT: callq ___stack_chk_fail
1314 ; DARWIN-X64: .cfi_endproc
1315 %c = alloca %struct.pair, align 4
1316 %b = alloca i32*, align 8
1317 %y = getelementptr inbounds %struct.pair* %c, i32 0, i32 1
1318 store i32* %y, i32** %b, align 8
1319 %0 = load i32** %b, align 8
1320 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i32* %0)
1321 ret void
1322 }
1323
1324 ; test11c: Addr-of struct element. (GEP followed by store).
1325 ; sspstrong attribute
1326 ; Requires protector.
1327 define void @test11c() nounwind uwtable sspstrong {
1328 entry:
1329 ; LINUX-I386-LABEL: test11c:
1330 ; LINUX-I386: mov{{l|q}} %gs:
1331 ; LINUX-I386: calll __stack_chk_fail
1332
1333 ; LINUX-X64-LABEL: test11c:
1334 ; LINUX-X64: mov{{l|q}} %fs:
1335 ; LINUX-X64: callq __stack_chk_fail
1336
1337 ; LINUX-KERNEL-X64-LABEL: test11c:
1338 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1339 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1340
1341 ; DARWIN-X64-LABEL: test11c:
1342 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
1343 ; DARWIN-X64: callq ___stack_chk_fail
1344 %c = alloca %struct.pair, align 4
1345 %b = alloca i32*, align 8
1346 %y = getelementptr inbounds %struct.pair* %c, i32 0, i32 1
1347 store i32* %y, i32** %b, align 8
1348 %0 = load i32** %b, align 8
1349 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i32* %0)
1350 ret void
1351 }
1352
1353 ; test11d: Addr-of struct element. (GEP followed by store).
1354 ; sspreq attribute
1355 ; Requires protector.
1356 define void @test11d() nounwind uwtable sspreq {
1357 entry:
1358 ; LINUX-I386-LABEL: test11d:
1359 ; LINUX-I386: mov{{l|q}} %gs:
1360 ; LINUX-I386: calll __stack_chk_fail
1361
1362 ; LINUX-X64-LABEL: test11d:
1363 ; LINUX-X64: mov{{l|q}} %fs:
1364 ; LINUX-X64: callq __stack_chk_fail
1365
1366 ; LINUX-KERNEL-X64-LABEL: test11d:
1367 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1368 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1369
1370 ; DARWIN-X64-LABEL: test11d:
1371 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
1372 ; DARWIN-X64: callq ___stack_chk_fail
1373 %c = alloca %struct.pair, align 4
1374 %b = alloca i32*, align 8
1375 %y = getelementptr inbounds %struct.pair* %c, i32 0, i32 1
1376 store i32* %y, i32** %b, align 8
1377 %0 = load i32** %b, align 8
1378 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i32* %0)
1379 ret void
1380 }
1381
1382 ; test12a: Addr-of struct element, GEP followed by ptrtoint.
1383 ; no ssp attribute
1384 ; Requires no protector.
1385 define void @test12a() nounwind uwtable {
1386 entry:
1387 ; LINUX-I386-LABEL: test12a:
1388 ; LINUX-I386-NOT: calll __stack_chk_fail
1389 ; LINUX-I386: .cfi_endproc
1390
1391 ; LINUX-X64-LABEL: test12a:
1392 ; LINUX-X64-NOT: callq __stack_chk_fail
1393 ; LINUX-X64: .cfi_endproc
1394
1395 ; LINUX-KERNEL-X64-LABEL: test12a:
1396 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1397 ; LINUX-KERNEL-X64: .cfi_endproc
1398
1399 ; DARWIN-X64-LABEL: test12a:
1400 ; DARWIN-X64-NOT: callq ___stack_chk_fail
1401 ; DARWIN-X64: .cfi_endproc
1402 %c = alloca %struct.pair, align 4
1403 %b = alloca i32*, align 8
1404 %y = getelementptr inbounds %struct.pair* %c, i32 0, i32 1
1405 %0 = ptrtoint i32* %y to i64
1406 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i64 %0)
1407 ret void
1408 }
1409
1410 ; test12b: Addr-of struct element, GEP followed by ptrtoint.
1411 ; ssp attribute
1412 ; Requires no protector.
1413 define void @test12b() nounwind uwtable ssp {
1414 entry:
1415 ; LINUX-I386-LABEL: test12b:
1416 ; LINUX-I386-NOT: calll __stack_chk_fail
1417 ; LINUX-I386: .cfi_endproc
1418
1419 ; LINUX-X64-LABEL: test12b:
1420 ; LINUX-X64-NOT: callq __stack_chk_fail
1421 ; LINUX-X64: .cfi_endproc
1422
1423 ; LINUX-KERNEL-X64-LABEL: test12b:
1424 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1425 ; LINUX-KERNEL-X64: .cfi_endproc
1426
1427 ; DARWIN-X64-LABEL: test12b:
1428 ; DARWIN-X64-NOT: callq ___stack_chk_fail
1429 ; DARWIN-X64: .cfi_endproc
1430 %c = alloca %struct.pair, align 4
1431 %b = alloca i32*, align 8
1432 %y = getelementptr inbounds %struct.pair* %c, i32 0, i32 1
1433 %0 = ptrtoint i32* %y to i64
1434 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i64 %0)
1435 ret void
1436 }
1437
1438 ; test12c: Addr-of struct element, GEP followed by ptrtoint.
1439 ; sspstrong attribute
1440 ; Requires protector.
1441 define void @test12c() nounwind uwtable sspstrong {
1442 entry:
1443 ; LINUX-I386-LABEL: test12c:
1444 ; LINUX-I386: mov{{l|q}} %gs:
1445 ; LINUX-I386: calll __stack_chk_fail
1446
1447 ; LINUX-X64-LABEL: test12c:
1448 ; LINUX-X64: mov{{l|q}} %fs:
1449 ; LINUX-X64: callq __stack_chk_fail
1450
1451 ; LINUX-KERNEL-X64-LABEL: test12c:
1452 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1453 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1454
1455 ; DARWIN-X64-LABEL: test12c:
1456 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
1457 ; DARWIN-X64: callq ___stack_chk_fail
1458 %c = alloca %struct.pair, align 4
1459 %b = alloca i32*, align 8
1460 %y = getelementptr inbounds %struct.pair* %c, i32 0, i32 1
1461 %0 = ptrtoint i32* %y to i64
1462 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i64 %0)
1463 ret void
1464 }
1465
1466 ; test12d: Addr-of struct element, GEP followed by ptrtoint.
1467 ; sspreq attribute
1468 ; Requires protector.
1469 define void @test12d() nounwind uwtable sspreq {
1470 entry:
1471 ; LINUX-I386-LABEL: test12d:
1472 ; LINUX-I386: mov{{l|q}} %gs:
1473 ; LINUX-I386: calll __stack_chk_fail
1474
1475 ; LINUX-X64-LABEL: test12d:
1476 ; LINUX-X64: mov{{l|q}} %fs:
1477 ; LINUX-X64: callq __stack_chk_fail
1478
1479 ; LINUX-KERNEL-X64-LABEL: test12d:
1480 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1481 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1482
1483 ; DARWIN-X64-LABEL: test12d:
1484 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
1485 ; DARWIN-X64: callq ___stack_chk_fail
1486 %c = alloca %struct.pair, align 4
1487 %b = alloca i32*, align 8
1488 %y = getelementptr inbounds %struct.pair* %c, i32 0, i32 1
1489 %0 = ptrtoint i32* %y to i64
1490 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i64 %0)
1491 ret void
1492 }
1493
1494 ; test13a: Addr-of struct element, GEP followed by callinst.
1495 ; no ssp attribute
1496 ; Requires no protector.
1497 define void @test13a() nounwind uwtable {
1498 entry:
1499 ; LINUX-I386-LABEL: test13a:
1500 ; LINUX-I386-NOT: calll __stack_chk_fail
1501 ; LINUX-I386: .cfi_endproc
1502
1503 ; LINUX-X64-LABEL: test13a:
1504 ; LINUX-X64-NOT: callq __stack_chk_fail
1505 ; LINUX-X64: .cfi_endproc
1506
1507 ; LINUX-KERNEL-X64-LABEL: test13a:
1508 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1509 ; LINUX-KERNEL-X64: .cfi_endproc
1510
1511 ; DARWIN-X64-LABEL: test13a:
1512 ; DARWIN-X64-NOT: callq ___stack_chk_fail
1513 ; DARWIN-X64: .cfi_endproc
1514 %c = alloca %struct.pair, align 4
1515 %y = getelementptr inbounds %struct.pair* %c, i64 0, i32 1
1516 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32* %y) nounwind
1517 ret void
1518 }
1519
1520 ; test13b: Addr-of struct element, GEP followed by callinst.
1521 ; ssp attribute
1522 ; Requires no protector.
1523 define void @test13b() nounwind uwtable ssp {
1524 entry:
1525 ; LINUX-I386-LABEL: test13b:
1526 ; LINUX-I386-NOT: calll __stack_chk_fail
1527 ; LINUX-I386: .cfi_endproc
1528
1529 ; LINUX-X64-LABEL: test13b:
1530 ; LINUX-X64-NOT: callq __stack_chk_fail
1531 ; LINUX-X64: .cfi_endproc
1532
1533 ; LINUX-KERNEL-X64-LABEL: test13b:
1534 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1535 ; LINUX-KERNEL-X64: .cfi_endproc
1536
1537 ; DARWIN-X64-LABEL: test13b:
1538 ; DARWIN-X64-NOT: callq ___stack_chk_fail
1539 ; DARWIN-X64: .cfi_endproc
1540 %c = alloca %struct.pair, align 4
1541 %y = getelementptr inbounds %struct.pair* %c, i64 0, i32 1
1542 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32* %y) nounwind
1543 ret void
1544 }
1545
1546 ; test13c: Addr-of struct element, GEP followed by callinst.
1547 ; sspstrong attribute
1548 ; Requires protector.
1549 define void @test13c() nounwind uwtable sspstrong {
1550 entry:
1551 ; LINUX-I386-LABEL: test13c:
1552 ; LINUX-I386: mov{{l|q}} %gs:
1553 ; LINUX-I386: calll __stack_chk_fail
1554
1555 ; LINUX-X64-LABEL: test13c:
1556 ; LINUX-X64: mov{{l|q}} %fs:
1557 ; LINUX-X64: callq __stack_chk_fail
1558
1559 ; LINUX-KERNEL-X64-LABEL: test13c:
1560 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1561 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1562
1563 ; DARWIN-X64-LABEL: test13c:
1564 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
1565 ; DARWIN-X64: callq ___stack_chk_fail
1566 %c = alloca %struct.pair, align 4
1567 %y = getelementptr inbounds %struct.pair* %c, i64 0, i32 1
1568 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32* %y) nounwind
1569 ret void
1570 }
1571
1572 ; test13d: Addr-of struct element, GEP followed by callinst.
1573 ; sspreq attribute
1574 ; Requires protector.
1575 define void @test13d() nounwind uwtable sspreq {
1576 entry:
1577 ; LINUX-I386-LABEL: test13d:
1578 ; LINUX-I386: mov{{l|q}} %gs:
1579 ; LINUX-I386: calll __stack_chk_fail
1580
1581 ; LINUX-X64-LABEL: test13d:
1582 ; LINUX-X64: mov{{l|q}} %fs:
1583 ; LINUX-X64: callq __stack_chk_fail
1584
1585 ; LINUX-KERNEL-X64-LABEL: test13d:
1586 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1587 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1588
1589 ; DARWIN-X64-LABEL: test13d:
1590 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
1591 ; DARWIN-X64: callq ___stack_chk_fail
1592 %c = alloca %struct.pair, align 4
1593 %y = getelementptr inbounds %struct.pair* %c, i64 0, i32 1
1594 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32* %y) nounwind
1595 ret void
1596 }
1597
1598 ; test14a: Addr-of a local, optimized into a GEP (e.g., &a - 12)
1599 ; no ssp attribute
1600 ; Requires no protector.
1601 define void @test14a() nounwind uwtable {
1602 entry:
1603 ; LINUX-I386-LABEL: test14a:
1604 ; LINUX-I386-NOT: calll __stack_chk_fail
1605 ; LINUX-I386: .cfi_endproc
1606
1607 ; LINUX-X64-LABEL: test14a:
1608 ; LINUX-X64-NOT: callq __stack_chk_fail
1609 ; LINUX-X64: .cfi_endproc
1610
1611 ; LINUX-KERNEL-X64-LABEL: test14a:
1612 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1613 ; LINUX-KERNEL-X64: .cfi_endproc
1614
1615 ; DARWIN-X64-LABEL: test14a:
1616 ; DARWIN-X64-NOT: callq ___stack_chk_fail
1617 ; DARWIN-X64: .cfi_endproc
1618 %a = alloca i32, align 4
1619 %add.ptr5 = getelementptr inbounds i32* %a, i64 -12
1620 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32* %add.ptr5) nounwind
1621 ret void
1622 }
1623
1624 ; test14b: Addr-of a local, optimized into a GEP (e.g., &a - 12)
1625 ; ssp attribute
1626 ; Requires no protector.
1627 define void @test14b() nounwind uwtable ssp {
1628 entry:
1629 ; LINUX-I386-LABEL: test14b:
1630 ; LINUX-I386-NOT: calll __stack_chk_fail
1631 ; LINUX-I386: .cfi_endproc
1632
1633 ; LINUX-X64-LABEL: test14b:
1634 ; LINUX-X64-NOT: callq __stack_chk_fail
1635 ; LINUX-X64: .cfi_endproc
1636
1637 ; LINUX-KERNEL-X64-LABEL: test14b:
1638 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1639 ; LINUX-KERNEL-X64: .cfi_endproc
1640
1641 ; DARWIN-X64-LABEL: test14b:
1642 ; DARWIN-X64-NOT: callq ___stack_chk_fail
1643 ; DARWIN-X64: .cfi_endproc
1644 %a = alloca i32, align 4
1645 %add.ptr5 = getelementptr inbounds i32* %a, i64 -12
1646 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32* %add.ptr5) nounwind
1647 ret void
1648 }
1649
1650 ; test14c: Addr-of a local, optimized into a GEP (e.g., &a - 12)
1651 ; sspstrong attribute
1652 ; Requires protector.
1653 define void @test14c() nounwind uwtable sspstrong {
1654 entry:
1655 ; LINUX-I386-LABEL: test14c:
1656 ; LINUX-I386: mov{{l|q}} %gs:
1657 ; LINUX-I386: calll __stack_chk_fail
1658
1659 ; LINUX-X64-LABEL: test14c:
1660 ; LINUX-X64: mov{{l|q}} %fs:
1661 ; LINUX-X64: callq __stack_chk_fail
1662
1663 ; LINUX-KERNEL-X64-LABEL: test14c:
1664 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1665 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1666
1667 ; DARWIN-X64-LABEL: test14c:
1668 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
1669 ; DARWIN-X64: callq ___stack_chk_fail
1670 %a = alloca i32, align 4
1671 %add.ptr5 = getelementptr inbounds i32* %a, i64 -12
1672 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32* %add.ptr5) nounwind
1673 ret void
1674 }
1675
1676 ; test14d: Addr-of a local, optimized into a GEP (e.g., &a - 12)
1677 ; sspreq attribute
1678 ; Requires protector.
1679 define void @test14d() nounwind uwtable sspreq {
1680 entry:
1681 ; LINUX-I386-LABEL: test14d:
1682 ; LINUX-I386: mov{{l|q}} %gs:
1683 ; LINUX-I386: calll __stack_chk_fail
1684
1685 ; LINUX-X64-LABEL: test14d:
1686 ; LINUX-X64: mov{{l|q}} %fs:
1687 ; LINUX-X64: callq __stack_chk_fail
1688
1689 ; LINUX-KERNEL-X64-LABEL: test14d:
1690 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1691 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1692
1693 ; DARWIN-X64-LABEL: test14d:
1694 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
1695 ; DARWIN-X64: callq ___stack_chk_fail
1696 %a = alloca i32, align 4
1697 %add.ptr5 = getelementptr inbounds i32* %a, i64 -12
1698 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32* %add.ptr5) nounwind
1699 ret void
1700 }
1701
1702 ; test15a: Addr-of a local cast to a ptr of a different type
1703 ; (e.g., int a; ... ; float *b = &a;)
1704 ; no ssp attribute
1705 ; Requires no protector.
1706 define void @test15a() nounwind uwtable {
1707 entry:
1708 ; LINUX-I386-LABEL: test15a:
1709 ; LINUX-I386-NOT: calll __stack_chk_fail
1710 ; LINUX-I386: .cfi_endproc
1711
1712 ; LINUX-X64-LABEL: test15a:
1713 ; LINUX-X64-NOT: callq __stack_chk_fail
1714 ; LINUX-X64: .cfi_endproc
1715
1716 ; LINUX-KERNEL-X64-LABEL: test15a:
1717 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1718 ; LINUX-KERNEL-X64: .cfi_endproc
1719
1720 ; DARWIN-X64-LABEL: test15a:
1721 ; DARWIN-X64-NOT: callq ___stack_chk_fail
1722 ; DARWIN-X64: .cfi_endproc
1723 %a = alloca i32, align 4
1724 %b = alloca float*, align 8
1725 store i32 0, i32* %a, align 4
1726 %0 = bitcast i32* %a to float*
1727 store float* %0, float** %b, align 8
1728 %1 = load float** %b, align 8
1729 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), float* %1)
1730 ret void
1731 }
1732
1733 ; test15b: Addr-of a local cast to a ptr of a different type
1734 ; (e.g., int a; ... ; float *b = &a;)
1735 ; ssp attribute
1736 ; Requires no protector.
1737 define void @test15b() nounwind uwtable ssp {
1738 entry:
1739 ; LINUX-I386-LABEL: test15b:
1740 ; LINUX-I386-NOT: calll __stack_chk_fail
1741 ; LINUX-I386: .cfi_endproc
1742
1743 ; LINUX-X64-LABEL: test15b:
1744 ; LINUX-X64-NOT: callq __stack_chk_fail
1745 ; LINUX-X64: .cfi_endproc
1746
1747 ; LINUX-KERNEL-X64-LABEL: test15b:
1748 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1749 ; LINUX-KERNEL-X64: .cfi_endproc
1750
1751 ; DARWIN-X64-LABEL: test15b:
1752 ; DARWIN-X64-NOT: callq ___stack_chk_fail
1753 ; DARWIN-X64: .cfi_endproc
1754 %a = alloca i32, align 4
1755 %b = alloca float*, align 8
1756 store i32 0, i32* %a, align 4
1757 %0 = bitcast i32* %a to float*
1758 store float* %0, float** %b, align 8
1759 %1 = load float** %b, align 8
1760 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), float* %1)
1761 ret void
1762 }
1763
1764 ; test15c: Addr-of a local cast to a ptr of a different type
1765 ; (e.g., int a; ... ; float *b = &a;)
1766 ; sspstrong attribute
1767 ; Requires protector.
1768 define void @test15c() nounwind uwtable sspstrong {
1769 entry:
1770 ; LINUX-I386-LABEL: test15c:
1771 ; LINUX-I386: mov{{l|q}} %gs:
1772 ; LINUX-I386: calll __stack_chk_fail
1773
1774 ; LINUX-X64-LABEL: test15c:
1775 ; LINUX-X64: mov{{l|q}} %fs:
1776 ; LINUX-X64: callq __stack_chk_fail
1777
1778 ; LINUX-KERNEL-X64-LABEL: test15c:
1779 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1780 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1781
1782 ; DARWIN-X64-LABEL: test15c:
1783 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
1784 ; DARWIN-X64: callq ___stack_chk_fail
1785 %a = alloca i32, align 4
1786 %b = alloca float*, align 8
1787 store i32 0, i32* %a, align 4
1788 %0 = bitcast i32* %a to float*
1789 store float* %0, float** %b, align 8
1790 %1 = load float** %b, align 8
1791 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), float* %1)
1792 ret void
1793 }
1794
1795 ; test15d: Addr-of a local cast to a ptr of a different type
1796 ; (e.g., int a; ... ; float *b = &a;)
1797 ; sspreq attribute
1798 ; Requires protector.
1799 define void @test15d() nounwind uwtable sspreq {
1800 entry:
1801 ; LINUX-I386-LABEL: test15d:
1802 ; LINUX-I386: mov{{l|q}} %gs:
1803 ; LINUX-I386: calll __stack_chk_fail
1804
1805 ; LINUX-X64-LABEL: test15d:
1806 ; LINUX-X64: mov{{l|q}} %fs:
1807 ; LINUX-X64: callq __stack_chk_fail
1808
1809 ; LINUX-KERNEL-X64-LABEL: test15d:
1810 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1811 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1812
1813 ; DARWIN-X64-LABEL: test15d:
1814 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
1815 ; DARWIN-X64: callq ___stack_chk_fail
1816 %a = alloca i32, align 4
1817 %b = alloca float*, align 8
1818 store i32 0, i32* %a, align 4
1819 %0 = bitcast i32* %a to float*
1820 store float* %0, float** %b, align 8
1821 %1 = load float** %b, align 8
1822 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), float* %1)
1823 ret void
1824 }
1825
1826 ; test16a: Addr-of a local cast to a ptr of a different type (optimized)
1827 ; (e.g., int a; ... ; float *b = &a;)
1828 ; no ssp attribute
1829 ; Requires no protector.
1830 define void @test16a() nounwind uwtable {
1831 entry:
1832 ; LINUX-I386-LABEL: test16a:
1833 ; LINUX-I386-NOT: calll __stack_chk_fail
1834 ; LINUX-I386: .cfi_endproc
1835
1836 ; LINUX-X64-LABEL: test16a:
1837 ; LINUX-X64-NOT: callq __stack_chk_fail
1838 ; LINUX-X64: .cfi_endproc
1839
1840 ; LINUX-KERNEL-X64-LABEL: test16a:
1841 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1842 ; LINUX-KERNEL-X64: .cfi_endproc
1843
1844 ; DARWIN-X64-LABEL: test16a:
1845 ; DARWIN-X64-NOT: callq ___stack_chk_fail
1846 ; DARWIN-X64: .cfi_endproc
1847 %a = alloca i32, align 4
1848 store i32 0, i32* %a, align 4
1849 %0 = bitcast i32* %a to float*
1850 call void @funfloat(float* %0) nounwind
1851 ret void
1852 }
1853
1854 ; test16b: Addr-of a local cast to a ptr of a different type (optimized)
1855 ; (e.g., int a; ... ; float *b = &a;)
1856 ; ssp attribute
1857 ; Requires no protector.
1858 define void @test16b() nounwind uwtable ssp {
1859 entry:
1860 ; LINUX-I386-LABEL: test16b:
1861 ; LINUX-I386-NOT: calll __stack_chk_fail
1862 ; LINUX-I386: .cfi_endproc
1863
1864 ; LINUX-X64-LABEL: test16b:
1865 ; LINUX-X64-NOT: callq __stack_chk_fail
1866 ; LINUX-X64: .cfi_endproc
1867
1868 ; LINUX-KERNEL-X64-LABEL: test16b:
1869 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1870 ; LINUX-KERNEL-X64: .cfi_endproc
1871
1872 ; DARWIN-X64-LABEL: test16b:
1873 ; DARWIN-X64-NOT: callq ___stack_chk_fail
1874 ; DARWIN-X64: .cfi_endproc
1875 %a = alloca i32, align 4
1876 store i32 0, i32* %a, align 4
1877 %0 = bitcast i32* %a to float*
1878 call void @funfloat(float* %0) nounwind
1879 ret void
1880 }
1881
1882 ; test16c: Addr-of a local cast to a ptr of a different type (optimized)
1883 ; (e.g., int a; ... ; float *b = &a;)
1884 ; sspstrong attribute
1885 ; Requires protector.
1886 define void @test16c() nounwind uwtable sspstrong {
1887 entry:
1888 ; LINUX-I386-LABEL: test16c:
1889 ; LINUX-I386: mov{{l|q}} %gs:
1890 ; LINUX-I386: calll __stack_chk_fail
1891
1892 ; LINUX-X64-LABEL: test16c:
1893 ; LINUX-X64: mov{{l|q}} %fs:
1894 ; LINUX-X64: callq __stack_chk_fail
1895
1896 ; LINUX-KERNEL-X64-LABEL: test16c:
1897 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1898 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1899
1900 ; DARWIN-X64-LABEL: test16c:
1901 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
1902 ; DARWIN-X64: callq ___stack_chk_fail
1903 %a = alloca i32, align 4
1904 store i32 0, i32* %a, align 4
1905 %0 = bitcast i32* %a to float*
1906 call void @funfloat(float* %0) nounwind
1907 ret void
1908 }
1909
1910 ; test16d: Addr-of a local cast to a ptr of a different type (optimized)
1911 ; (e.g., int a; ... ; float *b = &a;)
1912 ; sspreq attribute
1913 ; Requires protector.
1914 define void @test16d() nounwind uwtable sspreq {
1915 entry:
1916 ; LINUX-I386-LABEL: test16d:
1917 ; LINUX-I386: mov{{l|q}} %gs:
1918 ; LINUX-I386: calll __stack_chk_fail
1919
1920 ; LINUX-X64-LABEL: test16d:
1921 ; LINUX-X64: mov{{l|q}} %fs:
1922 ; LINUX-X64: callq __stack_chk_fail
1923
1924 ; LINUX-KERNEL-X64-LABEL: test16d:
1925 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1926 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1927
1928 ; DARWIN-X64-LABEL: test16d:
1929 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
1930 ; DARWIN-X64: callq ___stack_chk_fail
1931 %a = alloca i32, align 4
1932 store i32 0, i32* %a, align 4
1933 %0 = bitcast i32* %a to float*
1934 call void @funfloat(float* %0) nounwind
1935 ret void
1936 }
1937
1938 ; test17a: Addr-of a vector nested in a struct
1939 ; no ssp attribute
1940 ; Requires no protector.
1941 define void @test17a() nounwind uwtable {
1942 entry:
1943 ; LINUX-I386-LABEL: test17a:
1944 ; LINUX-I386-NOT: calll __stack_chk_fail
1945 ; LINUX-I386: .cfi_endproc
1946
1947 ; LINUX-X64-LABEL: test17a:
1948 ; LINUX-X64-NOT: callq __stack_chk_fail
1949 ; LINUX-X64: .cfi_endproc
1950
1951 ; LINUX-KERNEL-X64-LABEL: test17a:
1952 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1953 ; LINUX-KERNEL-X64: .cfi_endproc
1954
1955 ; DARWIN-X64-LABEL: test17a:
1956 ; DARWIN-X64-NOT: callq ___stack_chk_fail
1957 ; DARWIN-X64: .cfi_endproc
1958 %c = alloca %struct.vec, align 16
1959 %y = getelementptr inbounds %struct.vec* %c, i64 0, i32 0
1960 %add.ptr = getelementptr inbounds <4 x i32>* %y, i64 -12
1961 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), <4 x i32>* %add.ptr) nounwind
1962 ret void
1963 }
1964
1965 ; test17b: Addr-of a vector nested in a struct
1966 ; ssp attribute
1967 ; Requires no protector.
1968 define void @test17b() nounwind uwtable ssp {
1969 entry:
1970 ; LINUX-I386-LABEL: test17b:
1971 ; LINUX-I386-NOT: calll __stack_chk_fail
1972 ; LINUX-I386: .cfi_endproc
1973
1974 ; LINUX-X64-LABEL: test17b:
1975 ; LINUX-X64-NOT: callq __stack_chk_fail
1976 ; LINUX-X64: .cfi_endproc
1977
1978 ; LINUX-KERNEL-X64-LABEL: test17b:
1979 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1980 ; LINUX-KERNEL-X64: .cfi_endproc
1981
1982 ; DARWIN-X64-LABEL: test17b:
1983 ; DARWIN-X64-NOT: callq ___stack_chk_fail
1984 ; DARWIN-X64: .cfi_endproc
1985 %c = alloca %struct.vec, align 16
1986 %y = getelementptr inbounds %struct.vec* %c, i64 0, i32 0
1987 %add.ptr = getelementptr inbounds <4 x i32>* %y, i64 -12
1988 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), <4 x i32>* %add.ptr) nounwind
1989 ret void
1990 }
1991
1992 ; test17c: Addr-of a vector nested in a struct
1993 ; sspstrong attribute
1994 ; Requires protector.
1995 define void @test17c() nounwind uwtable sspstrong {
1996 entry:
1997 ; LINUX-I386-LABEL: test17c:
1998 ; LINUX-I386: mov{{l|q}} %gs:
1999 ; LINUX-I386: calll __stack_chk_fail
2000
2001 ; LINUX-X64-LABEL: test17c:
2002 ; LINUX-X64: mov{{l|q}} %fs:
2003 ; LINUX-X64: callq __stack_chk_fail
2004
2005 ; LINUX-KERNEL-X64-LABEL: test17c:
2006 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2007 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2008
2009 ; DARWIN-X64-LABEL: test17c:
2010 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2011 ; DARWIN-X64: callq ___stack_chk_fail
2012 %c = alloca %struct.vec, align 16
2013 %y = getelementptr inbounds %struct.vec* %c, i64 0, i32 0
2014 %add.ptr = getelementptr inbounds <4 x i32>* %y, i64 -12
2015 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), <4 x i32>* %add.ptr) nounwind
2016 ret void
2017 }
2018
2019 ; test17d: Addr-of a vector nested in a struct
2020 ; sspreq attribute
2021 ; Requires protector.
2022 define void @test17d() nounwind uwtable sspreq {
2023 entry:
2024 ; LINUX-I386-LABEL: test17d:
2025 ; LINUX-I386: mov{{l|q}} %gs:
2026 ; LINUX-I386: calll __stack_chk_fail
2027
2028 ; LINUX-X64-LABEL: test17d:
2029 ; LINUX-X64: mov{{l|q}} %fs:
2030 ; LINUX-X64: callq __stack_chk_fail
2031
2032 ; LINUX-KERNEL-X64-LABEL: test17d:
2033 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2034 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2035
2036 ; DARWIN-X64-LABEL: test17d:
2037 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2038 ; DARWIN-X64: callq ___stack_chk_fail
2039 %c = alloca %struct.vec, align 16
2040 %y = getelementptr inbounds %struct.vec* %c, i64 0, i32 0
2041 %add.ptr = getelementptr inbounds <4 x i32>* %y, i64 -12
2042 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), <4 x i32>* %add.ptr) nounwind
2043 ret void
2044 }
2045
2046 ; test18a: Addr-of a variable passed into an invoke instruction.
2047 ; no ssp attribute
2048 ; Requires no protector.
2049 define i32 @test18a() uwtable {
2050 entry:
2051 ; LINUX-I386-LABEL: test18a:
2052 ; LINUX-I386-NOT: calll __stack_chk_fail
2053 ; LINUX-I386: .cfi_endproc
2054
2055 ; LINUX-X64-LABEL: test18a:
2056 ; LINUX-X64-NOT: callq __stack_chk_fail
2057 ; LINUX-X64: .cfi_endproc
2058
2059 ; LINUX-KERNEL-X64-LABEL: test18a:
2060 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2061 ; LINUX-KERNEL-X64: .cfi_endproc
2062
2063 ; DARWIN-X64-LABEL: test18a:
2064 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2065 ; DARWIN-X64: .cfi_endproc
2066 %a = alloca i32, align 4
2067 %exn.slot = alloca i8*
2068 %ehselector.slot = alloca i32
2069 store i32 0, i32* %a, align 4
2070 invoke void @_Z3exceptPi(i32* %a)
2071 to label %invoke.cont unwind label %lpad
2072
2073 invoke.cont:
2074 ret i32 0
2075
2076 lpad:
2077 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
2078 catch i8* null
2079 ret i32 0
2080 }
2081
2082 ; test18b: Addr-of a variable passed into an invoke instruction.
2083 ; ssp attribute
2084 ; Requires no protector.
2085 define i32 @test18b() uwtable ssp {
2086 entry:
2087 ; LINUX-I386-LABEL: test18b:
2088 ; LINUX-I386-NOT: calll __stack_chk_fail
2089 ; LINUX-I386: .cfi_endproc
2090
2091 ; LINUX-X64-LABEL: test18b:
2092 ; LINUX-X64-NOT: callq __stack_chk_fail
2093 ; LINUX-X64: .cfi_endproc
2094
2095 ; LINUX-KERNEL-X64-LABEL: test18b:
2096 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2097 ; LINUX-KERNEL-X64: .cfi_endproc
2098
2099 ; DARWIN-X64-LABEL: test18b:
2100 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2101 ; DARWIN-X64: .cfi_endproc
2102 %a = alloca i32, align 4
2103 %exn.slot = alloca i8*
2104 %ehselector.slot = alloca i32
2105 store i32 0, i32* %a, align 4
2106 invoke void @_Z3exceptPi(i32* %a)
2107 to label %invoke.cont unwind label %lpad
2108
2109 invoke.cont:
2110 ret i32 0
2111
2112 lpad:
2113 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
2114 catch i8* null
2115 ret i32 0
2116 }
2117
2118 ; test18c: Addr-of a variable passed into an invoke instruction.
2119 ; sspstrong attribute
2120 ; Requires protector.
2121 define i32 @test18c() uwtable sspstrong {
2122 entry:
2123 ; LINUX-I386-LABEL: test18c:
2124 ; LINUX-I386: mov{{l|q}} %gs:
2125 ; LINUX-I386: calll __stack_chk_fail
2126
2127 ; LINUX-X64-LABEL: test18c:
2128 ; LINUX-X64: mov{{l|q}} %fs:
2129 ; LINUX-X64: callq __stack_chk_fail
2130
2131 ; LINUX-KERNEL-X64-LABEL: test18c:
2132 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2133 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2134
2135 ; DARWIN-X64-LABEL: test18c:
2136 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2137 ; DARWIN-X64: callq ___stack_chk_fail
2138 %a = alloca i32, align 4
2139 %exn.slot = alloca i8*
2140 %ehselector.slot = alloca i32
2141 store i32 0, i32* %a, align 4
2142 invoke void @_Z3exceptPi(i32* %a)
2143 to label %invoke.cont unwind label %lpad
2144
2145 invoke.cont:
2146 ret i32 0
2147
2148 lpad:
2149 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
2150 catch i8* null
2151 ret i32 0
2152 }
2153
2154 ; test18d: Addr-of a variable passed into an invoke instruction.
2155 ; sspreq attribute
2156 ; Requires protector.
2157 define i32 @test18d() uwtable sspreq {
2158 entry:
2159 ; LINUX-I386-LABEL: test18d:
2160 ; LINUX-I386: mov{{l|q}} %gs:
2161 ; LINUX-I386: calll __stack_chk_fail
2162
2163 ; LINUX-X64-LABEL: test18d:
2164 ; LINUX-X64: mov{{l|q}} %fs:
2165 ; LINUX-X64: callq __stack_chk_fail
2166
2167 ; LINUX-KERNEL-X64-LABEL: test18d:
2168 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2169 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2170
2171 ; DARWIN-X64-LABEL: test18d:
2172 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2173 ; DARWIN-X64: callq ___stack_chk_fail
2174 %a = alloca i32, align 4
2175 %exn.slot = alloca i8*
2176 %ehselector.slot = alloca i32
2177 store i32 0, i32* %a, align 4
2178 invoke void @_Z3exceptPi(i32* %a)
2179 to label %invoke.cont unwind label %lpad
2180
2181 invoke.cont:
2182 ret i32 0
2183
2184 lpad:
2185 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
2186 catch i8* null
2187 ret i32 0
2188 }
2189
2190 ; test19a: Addr-of a struct element passed into an invoke instruction.
2191 ; (GEP followed by an invoke)
2192 ; no ssp attribute
2193 ; Requires no protector.
2194 define i32 @test19a() uwtable {
2195 entry:
2196 ; LINUX-I386-LABEL: test19a:
2197 ; LINUX-I386-NOT: calll __stack_chk_fail
2198 ; LINUX-I386: .cfi_endproc
2199
2200 ; LINUX-X64-LABEL: test19a:
2201 ; LINUX-X64-NOT: callq __stack_chk_fail
2202 ; LINUX-X64: .cfi_endproc
2203
2204 ; LINUX-KERNEL-X64-LABEL: test19a:
2205 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2206 ; LINUX-KERNEL-X64: .cfi_endproc
2207
2208 ; DARWIN-X64-LABEL: test19a:
2209 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2210 ; DARWIN-X64: .cfi_endproc
2211 %c = alloca %struct.pair, align 4
2212 %exn.slot = alloca i8*
2213 %ehselector.slot = alloca i32
2214 %a = getelementptr inbounds %struct.pair* %c, i32 0, i32 0
2215 store i32 0, i32* %a, align 4
2216 %a1 = getelementptr inbounds %struct.pair* %c, i32 0, i32 0
2217 invoke void @_Z3exceptPi(i32* %a1)
2218 to label %invoke.cont unwind label %lpad
2219
2220 invoke.cont:
2221 ret i32 0
2222
2223 lpad:
2224 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
2225 catch i8* null
2226 ret i32 0
2227 }
2228
2229 ; test19b: Addr-of a struct element passed into an invoke instruction.
2230 ; (GEP followed by an invoke)
2231 ; ssp attribute
2232 ; Requires no protector.
2233 define i32 @test19b() uwtable ssp {
2234 entry:
2235 ; LINUX-I386-LABEL: test19b:
2236 ; LINUX-I386-NOT: calll __stack_chk_fail
2237 ; LINUX-I386: .cfi_endproc
2238
2239 ; LINUX-X64-LABEL: test19b:
2240 ; LINUX-X64-NOT: callq __stack_chk_fail
2241 ; LINUX-X64: .cfi_endproc
2242
2243 ; LINUX-KERNEL-X64-LABEL: test19b:
2244 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2245 ; LINUX-KERNEL-X64: .cfi_endproc
2246
2247 ; DARWIN-X64-LABEL: test19b:
2248 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2249 ; DARWIN-X64: .cfi_endproc
2250 %c = alloca %struct.pair, align 4
2251 %exn.slot = alloca i8*
2252 %ehselector.slot = alloca i32
2253 %a = getelementptr inbounds %struct.pair* %c, i32 0, i32 0
2254 store i32 0, i32* %a, align 4
2255 %a1 = getelementptr inbounds %struct.pair* %c, i32 0, i32 0
2256 invoke void @_Z3exceptPi(i32* %a1)
2257 to label %invoke.cont unwind label %lpad
2258
2259 invoke.cont:
2260 ret i32 0
2261
2262 lpad:
2263 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
2264 catch i8* null
2265 ret i32 0
2266 }
2267
2268 ; test19c: Addr-of a struct element passed into an invoke instruction.
2269 ; (GEP followed by an invoke)
2270 ; sspstrong attribute
2271 ; Requires protector.
2272 define i32 @test19c() uwtable sspstrong {
2273 entry:
2274 ; LINUX-I386-LABEL: test19c:
2275 ; LINUX-I386: mov{{l|q}} %gs:
2276 ; LINUX-I386: calll __stack_chk_fail
2277
2278 ; LINUX-X64-LABEL: test19c:
2279 ; LINUX-X64: mov{{l|q}} %fs:
2280 ; LINUX-X64: callq __stack_chk_fail
2281
2282 ; LINUX-KERNEL-X64-LABEL: test19c:
2283 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2284 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2285
2286 ; DARWIN-X64-LABEL: test19c:
2287 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2288 ; DARWIN-X64: callq ___stack_chk_fail
2289 %c = alloca %struct.pair, align 4
2290 %exn.slot = alloca i8*
2291 %ehselector.slot = alloca i32
2292 %a = getelementptr inbounds %struct.pair* %c, i32 0, i32 0
2293 store i32 0, i32* %a, align 4
2294 %a1 = getelementptr inbounds %struct.pair* %c, i32 0, i32 0
2295 invoke void @_Z3exceptPi(i32* %a1)
2296 to label %invoke.cont unwind label %lpad
2297
2298 invoke.cont:
2299 ret i32 0
2300
2301 lpad:
2302 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
2303 catch i8* null
2304 ret i32 0
2305 }
2306
2307 ; test19d: Addr-of a struct element passed into an invoke instruction.
2308 ; (GEP followed by an invoke)
2309 ; sspreq attribute
2310 ; Requires protector.
2311 define i32 @test19d() uwtable sspreq {
2312 entry:
2313 ; LINUX-I386-LABEL: test19d:
2314 ; LINUX-I386: mov{{l|q}} %gs:
2315 ; LINUX-I386: calll __stack_chk_fail
2316 ; LINUX-I386-NOT: calll __stack_chk_fail
2317
2318 ; LINUX-X64-LABEL: test19d:
2319 ; LINUX-X64: mov{{l|q}} %fs:
2320 ; LINUX-X64: callq __stack_chk_fail
2321 ; LINUX-X64-NOT: callq __stack_chk_fail
2322
2323 ; LINUX-KERNEL-X64-LABEL: test19d:
2324 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2325 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2326 ; LINUX-KERNEL-X64-NOT: callq ___stack_chk_fail
2327
2328 ; DARWIN-X64-LABEL: test19d:
2329 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2330 ; DARWIN-X64: callq ___stack_chk_fail
2331 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2332 %c = alloca %struct.pair, align 4
2333 %exn.slot = alloca i8*
2334 %ehselector.slot = alloca i32
2335 %a = getelementptr inbounds %struct.pair* %c, i32 0, i32 0
2336 store i32 0, i32* %a, align 4
2337 %a1 = getelementptr inbounds %struct.pair* %c, i32 0, i32 0
2338 invoke void @_Z3exceptPi(i32* %a1)
2339 to label %invoke.cont unwind label %lpad
2340
2341 invoke.cont:
2342 ret i32 0
2343
2344 lpad:
2345 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
2346 catch i8* null
2347 ret i32 0
2348 }
2349
2350 ; test20a: Addr-of a pointer
2351 ; no ssp attribute
2352 ; Requires no protector.
2353 define void @test20a() nounwind uwtable {
2354 entry:
2355 ; LINUX-I386-LABEL: test20a:
2356 ; LINUX-I386-NOT: calll __stack_chk_fail
2357 ; LINUX-I386: .cfi_endproc
2358
2359 ; LINUX-X64-LABEL: test20a:
2360 ; LINUX-X64-NOT: callq __stack_chk_fail
2361 ; LINUX-X64: .cfi_endproc
2362
2363 ; LINUX-KERNEL-X64-LABEL: test20a:
2364 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2365 ; LINUX-KERNEL-X64: .cfi_endproc
2366
2367 ; DARWIN-X64-LABEL: test20a:
2368 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2369 ; DARWIN-X64: .cfi_endproc
2370 %a = alloca i32*, align 8
2371 %b = alloca i32**, align 8
2372 %call = call i32* @getp()
2373 store i32* %call, i32** %a, align 8
2374 store i32** %a, i32*** %b, align 8
2375 %0 = load i32*** %b, align 8
2376 call void @funcall2(i32** %0)
2377 ret void
2378 }
2379
2380 ; test20b: Addr-of a pointer
2381 ; ssp attribute
2382 ; Requires no protector.
2383 define void @test20b() nounwind uwtable ssp {
2384 entry:
2385 ; LINUX-I386-LABEL: test20b:
2386 ; LINUX-I386-NOT: calll __stack_chk_fail
2387 ; LINUX-I386: .cfi_endproc
2388
2389 ; LINUX-X64-LABEL: test20b:
2390 ; LINUX-X64-NOT: callq __stack_chk_fail
2391 ; LINUX-X64: .cfi_endproc
2392
2393 ; LINUX-KERNEL-X64-LABEL: test20b:
2394 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2395 ; LINUX-KERNEL-X64: .cfi_endproc
2396
2397 ; DARWIN-X64-LABEL: test20b:
2398 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2399 ; DARWIN-X64: .cfi_endproc
2400 %a = alloca i32*, align 8
2401 %b = alloca i32**, align 8
2402 %call = call i32* @getp()
2403 store i32* %call, i32** %a, align 8
2404 store i32** %a, i32*** %b, align 8
2405 %0 = load i32*** %b, align 8
2406 call void @funcall2(i32** %0)
2407 ret void
2408 }
2409
2410 ; test20c: Addr-of a pointer
2411 ; sspstrong attribute
2412 ; Requires protector.
2413 define void @test20c() nounwind uwtable sspstrong {
2414 entry:
2415 ; LINUX-I386-LABEL: test20c:
2416 ; LINUX-I386: mov{{l|q}} %gs:
2417 ; LINUX-I386: calll __stack_chk_fail
2418
2419 ; LINUX-X64-LABEL: test20c:
2420 ; LINUX-X64: mov{{l|q}} %fs:
2421 ; LINUX-X64: callq __stack_chk_fail
2422
2423 ; LINUX-KERNEL-X64-LABEL: test20c:
2424 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2425 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2426
2427 ; DARWIN-X64-LABEL: test20c:
2428 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2429 ; DARWIN-X64: callq ___stack_chk_fail
2430 %a = alloca i32*, align 8
2431 %b = alloca i32**, align 8
2432 %call = call i32* @getp()
2433 store i32* %call, i32** %a, align 8
2434 store i32** %a, i32*** %b, align 8
2435 %0 = load i32*** %b, align 8
2436 call void @funcall2(i32** %0)
2437 ret void
2438 }
2439
2440 ; test20d: Addr-of a pointer
2441 ; sspreq attribute
2442 ; Requires protector.
2443 define void @test20d() nounwind uwtable sspreq {
2444 entry:
2445 ; LINUX-I386-LABEL: test20d:
2446 ; LINUX-I386: mov{{l|q}} %gs:
2447 ; LINUX-I386: calll __stack_chk_fail
2448
2449 ; LINUX-X64-LABEL: test20d:
2450 ; LINUX-X64: mov{{l|q}} %fs:
2451 ; LINUX-X64: callq __stack_chk_fail
2452
2453 ; LINUX-KERNEL-X64-LABEL: test20d:
2454 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2455 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2456
2457 ; DARWIN-X64-LABEL: test20d:
2458 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2459 ; DARWIN-X64: callq ___stack_chk_fail
2460 %a = alloca i32*, align 8
2461 %b = alloca i32**, align 8
2462 %call = call i32* @getp()
2463 store i32* %call, i32** %a, align 8
2464 store i32** %a, i32*** %b, align 8
2465 %0 = load i32*** %b, align 8
2466 call void @funcall2(i32** %0)
2467 ret void
2468 }
2469
2470 ; test21a: Addr-of a casted pointer
2471 ; no ssp attribute
2472 ; Requires no protector.
2473 define void @test21a() nounwind uwtable {
2474 entry:
2475 ; LINUX-I386-LABEL: test21a:
2476 ; LINUX-I386-NOT: calll __stack_chk_fail
2477 ; LINUX-I386: .cfi_endproc
2478
2479 ; LINUX-X64-LABEL: test21a:
2480 ; LINUX-X64-NOT: callq __stack_chk_fail
2481 ; LINUX-X64: .cfi_endproc
2482
2483 ; LINUX-KERNEL-X64-LABEL: test21a:
2484 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2485 ; LINUX-KERNEL-X64: .cfi_endproc
2486
2487 ; DARWIN-X64-LABEL: test21a:
2488 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2489 ; DARWIN-X64: .cfi_endproc
2490 %a = alloca i32*, align 8
2491 %b = alloca float**, align 8
2492 %call = call i32* @getp()
2493 store i32* %call, i32** %a, align 8
2494 %0 = bitcast i32** %a to float**
2495 store float** %0, float*** %b, align 8
2496 %1 = load float*** %b, align 8
2497 call void @funfloat2(float** %1)
2498 ret void
2499 }
2500
2501 ; test21b: Addr-of a casted pointer
2502 ; ssp attribute
2503 ; Requires no protector.
2504 define void @test21b() nounwind uwtable ssp {
2505 entry:
2506 ; LINUX-I386-LABEL: test21b:
2507 ; LINUX-I386-NOT: calll __stack_chk_fail
2508 ; LINUX-I386: .cfi_endproc
2509
2510 ; LINUX-X64-LABEL: test21b:
2511 ; LINUX-X64-NOT: callq __stack_chk_fail
2512 ; LINUX-X64: .cfi_endproc
2513
2514 ; LINUX-KERNEL-X64-LABEL: test21b:
2515 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2516 ; LINUX-KERNEL-X64: .cfi_endproc
2517
2518 ; DARWIN-X64-LABEL: test21b:
2519 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2520 ; DARWIN-X64: .cfi_endproc
2521 %a = alloca i32*, align 8
2522 %b = alloca float**, align 8
2523 %call = call i32* @getp()
2524 store i32* %call, i32** %a, align 8
2525 %0 = bitcast i32** %a to float**
2526 store float** %0, float*** %b, align 8
2527 %1 = load float*** %b, align 8
2528 call void @funfloat2(float** %1)
2529 ret void
2530 }
2531
2532 ; test21c: Addr-of a casted pointer
2533 ; sspstrong attribute
2534 ; Requires protector.
2535 define void @test21c() nounwind uwtable sspstrong {
2536 entry:
2537 ; LINUX-I386-LABEL: test21c:
2538 ; LINUX-I386: mov{{l|q}} %gs:
2539 ; LINUX-I386: calll __stack_chk_fail
2540
2541 ; LINUX-X64-LABEL: test21c:
2542 ; LINUX-X64: mov{{l|q}} %fs:
2543 ; LINUX-X64: callq __stack_chk_fail
2544
2545 ; LINUX-KERNEL-X64-LABEL: test21c:
2546 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2547 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2548
2549 ; DARWIN-X64-LABEL: test21c:
2550 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2551 ; DARWIN-X64: callq ___stack_chk_fail
2552 %a = alloca i32*, align 8
2553 %b = alloca float**, align 8
2554 %call = call i32* @getp()
2555 store i32* %call, i32** %a, align 8
2556 %0 = bitcast i32** %a to float**
2557 store float** %0, float*** %b, align 8
2558 %1 = load float*** %b, align 8
2559 call void @funfloat2(float** %1)
2560 ret void
2561 }
2562
2563 ; test21d: Addr-of a casted pointer
2564 ; sspreq attribute
2565 ; Requires protector.
2566 define void @test21d() nounwind uwtable sspreq {
2567 entry:
2568 ; LINUX-I386-LABEL: test21d:
2569 ; LINUX-I386: mov{{l|q}} %gs:
2570 ; LINUX-I386: calll __stack_chk_fail
2571
2572 ; LINUX-X64-LABEL: test21d:
2573 ; LINUX-X64: mov{{l|q}} %fs:
2574 ; LINUX-X64: callq __stack_chk_fail
2575
2576 ; LINUX-KERNEL-X64-LABEL: test21d:
2577 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2578 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2579
2580 ; DARWIN-X64-LABEL: test21d:
2581 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2582 ; DARWIN-X64: callq ___stack_chk_fail
2583 %a = alloca i32*, align 8
2584 %b = alloca float**, align 8
2585 %call = call i32* @getp()
2586 store i32* %call, i32** %a, align 8
2587 %0 = bitcast i32** %a to float**
2588 store float** %0, float*** %b, align 8
2589 %1 = load float*** %b, align 8
2590 call void @funfloat2(float** %1)
2591 ret void
2592 }
2593
2594 ; test22a: [2 x i8] in a class
2595 ; no ssp attribute
2596 ; Requires no protector.
2597 define signext i8 @test22a() nounwind uwtable {
2598 entry:
2599 ; LINUX-I386-LABEL: test22a:
2600 ; LINUX-I386-NOT: calll __stack_chk_fail
2601 ; LINUX-I386: .cfi_endproc
2602
2603 ; LINUX-X64-LABEL: test22a:
2604 ; LINUX-X64-NOT: callq __stack_chk_fail
2605 ; LINUX-X64: .cfi_endproc
2606
2607 ; LINUX-KERNEL-X64-LABEL: test22a:
2608 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2609 ; LINUX-KERNEL-X64: .cfi_endproc
2610
2611 ; DARWIN-X64-LABEL: test22a:
2612 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2613 ; DARWIN-X64: .cfi_endproc
2614 %a = alloca %class.A, align 1
2615 %array = getelementptr inbounds %class.A* %a, i32 0, i32 0
2616 %arrayidx = getelementptr inbounds [2 x i8]* %array, i32 0, i64 0
2617 %0 = load i8* %arrayidx, align 1
2618 ret i8 %0
2619 }
2620
2621 ; test22b: [2 x i8] in a class
2622 ; ssp attribute
2623 ; Requires no protector.
2624 define signext i8 @test22b() nounwind uwtable ssp {
2625 entry:
2626 ; LINUX-I386-LABEL: test22b:
2627 ; LINUX-I386-NOT: calll __stack_chk_fail
2628 ; LINUX-I386: .cfi_endproc
2629
2630 ; LINUX-X64-LABEL: test22b:
2631 ; LINUX-X64-NOT: callq __stack_chk_fail
2632 ; LINUX-X64: .cfi_endproc
2633
2634 ; LINUX-KERNEL-X64-LABEL: test22b:
2635 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2636 ; LINUX-KERNEL-X64: .cfi_endproc
2637
2638 ; DARWIN-X64-LABEL: test22b:
2639 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2640 ; DARWIN-X64: .cfi_endproc
2641 %a = alloca %class.A, align 1
2642 %array = getelementptr inbounds %class.A* %a, i32 0, i32 0
2643 %arrayidx = getelementptr inbounds [2 x i8]* %array, i32 0, i64 0
2644 %0 = load i8* %arrayidx, align 1
2645 ret i8 %0
2646 }
2647
2648 ; test22c: [2 x i8] in a class
2649 ; sspstrong attribute
2650 ; Requires protector.
2651 define signext i8 @test22c() nounwind uwtable sspstrong {
2652 entry:
2653 ; LINUX-I386-LABEL: test22c:
2654 ; LINUX-I386: mov{{l|q}} %gs:
2655 ; LINUX-I386: calll __stack_chk_fail
2656
2657 ; LINUX-X64-LABEL: test22c:
2658 ; LINUX-X64: mov{{l|q}} %fs:
2659 ; LINUX-X64: callq __stack_chk_fail
2660
2661 ; LINUX-KERNEL-X64-LABEL: test22c:
2662 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2663 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2664
2665 ; DARWIN-X64-LABEL: test22c:
2666 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2667 ; DARWIN-X64: callq ___stack_chk_fail
2668 %a = alloca %class.A, align 1
2669 %array = getelementptr inbounds %class.A* %a, i32 0, i32 0
2670 %arrayidx = getelementptr inbounds [2 x i8]* %array, i32 0, i64 0
2671 %0 = load i8* %arrayidx, align 1
2672 ret i8 %0
2673 }
2674
2675 ; test22d: [2 x i8] in a class
2676 ; sspreq attribute
2677 ; Requires protector.
2678 define signext i8 @test22d() nounwind uwtable sspreq {
2679 entry:
2680 ; LINUX-I386-LABEL: test22d:
2681 ; LINUX-I386: mov{{l|q}} %gs:
2682 ; LINUX-I386: calll __stack_chk_fail
2683
2684 ; LINUX-X64-LABEL: test22d:
2685 ; LINUX-X64: mov{{l|q}} %fs:
2686 ; LINUX-X64: callq __stack_chk_fail
2687
2688 ; LINUX-KERNEL-X64-LABEL: test22d:
2689 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2690 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2691
2692 ; DARWIN-X64-LABEL: test22d:
2693 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2694 ; DARWIN-X64: callq ___stack_chk_fail
2695 %a = alloca %class.A, align 1
2696 %array = getelementptr inbounds %class.A* %a, i32 0, i32 0
2697 %arrayidx = getelementptr inbounds [2 x i8]* %array, i32 0, i64 0
2698 %0 = load i8* %arrayidx, align 1
2699 ret i8 %0
2700 }
2701
2702 ; test23a: [2 x i8] nested in several layers of structs and unions
2703 ; no ssp attribute
2704 ; Requires no protector.
2705 define signext i8 @test23a() nounwind uwtable {
2706 entry:
2707 ; LINUX-I386-LABEL: test23a:
2708 ; LINUX-I386-NOT: calll __stack_chk_fail
2709 ; LINUX-I386: .cfi_endproc
2710
2711 ; LINUX-X64-LABEL: test23a:
2712 ; LINUX-X64-NOT: callq __stack_chk_fail
2713 ; LINUX-X64: .cfi_endproc
2714
2715 ; LINUX-KERNEL-X64-LABEL: test23a:
2716 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2717 ; LINUX-KERNEL-X64: .cfi_endproc
2718
2719 ; DARWIN-X64-LABEL: test23a:
2720 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2721 ; DARWIN-X64: .cfi_endproc
2722 %x = alloca %struct.deep, align 1
2723 %b = getelementptr inbounds %struct.deep* %x, i32 0, i32 0
2724 %c = bitcast %union.anon* %b to %struct.anon*
2725 %d = getelementptr inbounds %struct.anon* %c, i32 0, i32 0
2726 %e = getelementptr inbounds %struct.anon.0* %d, i32 0, i32 0
2727 %array = bitcast %union.anon.1* %e to [2 x i8]*
2728 %arrayidx = getelementptr inbounds [2 x i8]* %array, i32 0, i64 0
2729 %0 = load i8* %arrayidx, align 1
2730 ret i8 %0
2731 }
2732
2733 ; test23b: [2 x i8] nested in several layers of structs and unions
2734 ; ssp attribute
2735 ; Requires no protector.
2736 define signext i8 @test23b() nounwind uwtable ssp {
2737 entry:
2738 ; LINUX-I386-LABEL: test23b:
2739 ; LINUX-I386-NOT: calll __stack_chk_fail
2740 ; LINUX-I386: .cfi_endproc
2741
2742 ; LINUX-X64-LABEL: test23b:
2743 ; LINUX-X64-NOT: callq __stack_chk_fail
2744 ; LINUX-X64: .cfi_endproc
2745
2746 ; LINUX-KERNEL-X64-LABEL: test23b:
2747 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2748 ; LINUX-KERNEL-X64: .cfi_endproc
2749
2750 ; DARWIN-X64-LABEL: test23b:
2751 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2752 ; DARWIN-X64: .cfi_endproc
2753 %x = alloca %struct.deep, align 1
2754 %b = getelementptr inbounds %struct.deep* %x, i32 0, i32 0
2755 %c = bitcast %union.anon* %b to %struct.anon*
2756 %d = getelementptr inbounds %struct.anon* %c, i32 0, i32 0
2757 %e = getelementptr inbounds %struct.anon.0* %d, i32 0, i32 0
2758 %array = bitcast %union.anon.1* %e to [2 x i8]*
2759 %arrayidx = getelementptr inbounds [2 x i8]* %array, i32 0, i64 0
2760 %0 = load i8* %arrayidx, align 1
2761 ret i8 %0
2762 }
2763
2764 ; test23c: [2 x i8] nested in several layers of structs and unions
2765 ; sspstrong attribute
2766 ; Requires protector.
2767 define signext i8 @test23c() nounwind uwtable sspstrong {
2768 entry:
2769 ; LINUX-I386-LABEL: test23c:
2770 ; LINUX-I386: mov{{l|q}} %gs:
2771 ; LINUX-I386: calll __stack_chk_fail
2772
2773 ; LINUX-X64-LABEL: test23c:
2774 ; LINUX-X64: mov{{l|q}} %fs:
2775 ; LINUX-X64: callq __stack_chk_fail
2776
2777 ; LINUX-KERNEL-X64-LABEL: test23c:
2778 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2779 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2780
2781 ; DARWIN-X64-LABEL: test23c:
2782 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2783 ; DARWIN-X64: callq ___stack_chk_fail
2784 %x = alloca %struct.deep, align 1
2785 %b = getelementptr inbounds %struct.deep* %x, i32 0, i32 0
2786 %c = bitcast %union.anon* %b to %struct.anon*
2787 %d = getelementptr inbounds %struct.anon* %c, i32 0, i32 0
2788 %e = getelementptr inbounds %struct.anon.0* %d, i32 0, i32 0
2789 %array = bitcast %union.anon.1* %e to [2 x i8]*
2790 %arrayidx = getelementptr inbounds [2 x i8]* %array, i32 0, i64 0
2791 %0 = load i8* %arrayidx, align 1
2792 ret i8 %0
2793 }
2794
2795 ; test23d: [2 x i8] nested in several layers of structs and unions
2796 ; sspreq attribute
2797 ; Requires protector.
2798 define signext i8 @test23d() nounwind uwtable sspreq {
2799 entry:
2800 ; LINUX-I386-LABEL: test23d:
2801 ; LINUX-I386: mov{{l|q}} %gs:
2802 ; LINUX-I386: calll __stack_chk_fail
2803
2804 ; LINUX-X64-LABEL: test23d:
2805 ; LINUX-X64: mov{{l|q}} %fs:
2806 ; LINUX-X64: callq __stack_chk_fail
2807
2808 ; LINUX-KERNEL-X64-LABEL: test23d:
2809 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2810 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2811
2812 ; DARWIN-X64-LABEL: test23d:
2813 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2814 ; DARWIN-X64: callq ___stack_chk_fail
2815 %x = alloca %struct.deep, align 1
2816 %b = getelementptr inbounds %struct.deep* %x, i32 0, i32 0
2817 %c = bitcast %union.anon* %b to %struct.anon*
2818 %d = getelementptr inbounds %struct.anon* %c, i32 0, i32 0
2819 %e = getelementptr inbounds %struct.anon.0* %d, i32 0, i32 0
2820 %array = bitcast %union.anon.1* %e to [2 x i8]*
2821 %arrayidx = getelementptr inbounds [2 x i8]* %array, i32 0, i64 0
2822 %0 = load i8* %arrayidx, align 1
2823 ret i8 %0
2824 }
2825
2826 ; test24a: Variable sized alloca
2827 ; no ssp attribute
2828 ; Requires no protector.
2829 define void @test24a(i32 %n) nounwind uwtable {
2830 entry:
2831 ; LINUX-I386-LABEL: test24a:
2832 ; LINUX-I386-NOT: calll __stack_chk_fail
2833 ; LINUX-I386: .cfi_endproc
2834
2835 ; LINUX-X64-LABEL: test24a:
2836 ; LINUX-X64-NOT: callq __stack_chk_fail
2837 ; LINUX-X64: .cfi_endproc
2838
2839 ; LINUX-KERNEL-X64-LABEL: test24a:
2840 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2841 ; LINUX-KERNEL-X64: .cfi_endproc
2842
2843 ; DARWIN-X64-LABEL: test24a:
2844 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2845 ; DARWIN-X64: .cfi_endproc
2846 %n.addr = alloca i32, align 4
2847 %a = alloca i32*, align 8
2848 store i32 %n, i32* %n.addr, align 4
2849 %0 = load i32* %n.addr, align 4
2850 %conv = sext i32 %0 to i64
2851 %1 = alloca i8, i64 %conv
2852 %2 = bitcast i8* %1 to i32*
2853 store i32* %2, i32** %a, align 8
2854 ret void
2855 }
2856
2857 ; test24b: Variable sized alloca
2858 ; ssp attribute
2859 ; Requires protector.
2860 define void @test24b(i32 %n) nounwind uwtable ssp {
2861 entry:
2862 ; LINUX-I386-LABEL: test24b:
2863 ; LINUX-I386: mov{{l|q}} %gs:
2864 ; LINUX-I386: calll __stack_chk_fail
2865
2866 ; LINUX-X64-LABEL: test24b:
2867 ; LINUX-X64: mov{{l|q}} %fs:
2868 ; LINUX-X64: callq __stack_chk_fail
2869
2870 ; LINUX-KERNEL-X64-LABEL: test24b:
2871 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2872 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2873
2874 ; DARWIN-X64-LABEL: test24b:
2875 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2876 ; DARWIN-X64: callq ___stack_chk_fail
2877 %n.addr = alloca i32, align 4
2878 %a = alloca i32*, align 8
2879 store i32 %n, i32* %n.addr, align 4
2880 %0 = load i32* %n.addr, align 4
2881 %conv = sext i32 %0 to i64
2882 %1 = alloca i8, i64 %conv
2883 %2 = bitcast i8* %1 to i32*
2884 store i32* %2, i32** %a, align 8
2885 ret void
2886 }
2887
2888 ; test24c: Variable sized alloca
2889 ; sspstrong attribute
2890 ; Requires protector.
2891 define void @test24c(i32 %n) nounwind uwtable sspstrong {
2892 entry:
2893 ; LINUX-I386-LABEL: test24c:
2894 ; LINUX-I386: mov{{l|q}} %gs:
2895 ; LINUX-I386: calll __stack_chk_fail
2896
2897 ; LINUX-X64-LABEL: test24c:
2898 ; LINUX-X64: mov{{l|q}} %fs:
2899 ; LINUX-X64: callq __stack_chk_fail
2900
2901 ; LINUX-KERNEL-X64-LABEL: test24c:
2902 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2903 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2904
2905 ; DARWIN-X64-LABEL: test24c:
2906 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2907 ; DARWIN-X64: callq ___stack_chk_fail
2908 %n.addr = alloca i32, align 4
2909 %a = alloca i32*, align 8
2910 store i32 %n, i32* %n.addr, align 4
2911 %0 = load i32* %n.addr, align 4
2912 %conv = sext i32 %0 to i64
2913 %1 = alloca i8, i64 %conv
2914 %2 = bitcast i8* %1 to i32*
2915 store i32* %2, i32** %a, align 8
2916 ret void
2917 }
2918
2919 ; test24d: Variable sized alloca
2920 ; sspreq attribute
2921 ; Requires protector.
2922 define void @test24d(i32 %n) nounwind uwtable sspreq {
2923 entry:
2924 ; LINUX-I386-LABEL: test24d:
2925 ; LINUX-I386: mov{{l|q}} %gs:
2926 ; LINUX-I386: calll __stack_chk_fail
2927
2928 ; LINUX-X64-LABEL: test24d:
2929 ; LINUX-X64: mov{{l|q}} %fs:
2930 ; LINUX-X64: callq __stack_chk_fail
2931
2932 ; LINUX-KERNEL-X64-LABEL: test24d:
2933 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2934 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2935
2936 ; DARWIN-X64-LABEL: test24d:
2937 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2938 ; DARWIN-X64: callq ___stack_chk_fail
2939 %n.addr = alloca i32, align 4
2940 %a = alloca i32*, align 8
2941 store i32 %n, i32* %n.addr, align 4
2942 %0 = load i32* %n.addr, align 4
2943 %conv = sext i32 %0 to i64
2944 %1 = alloca i8, i64 %conv
2945 %2 = bitcast i8* %1 to i32*
2946 store i32* %2, i32** %a, align 8
2947 ret void
2948 }
2949
2950 ; test25a: array of [4 x i32]
2951 ; no ssp attribute
2952 ; Requires no protector.
2953 define i32 @test25a() nounwind uwtable {
2954 entry:
2955 ; LINUX-I386-LABEL: test25a:
2956 ; LINUX-I386-NOT: calll __stack_chk_fail
2957 ; LINUX-I386: .cfi_endproc
2958
2959 ; LINUX-X64-LABEL: test25a:
2960 ; LINUX-X64-NOT: callq __stack_chk_fail
2961 ; LINUX-X64: .cfi_endproc
2962
2963 ; LINUX-KERNEL-X64-LABEL: test25a:
2964 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2965 ; LINUX-KERNEL-X64: .cfi_endproc
2966
2967 ; DARWIN-X64-LABEL: test25a:
2968 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2969 ; DARWIN-X64: .cfi_endproc
2970 %a = alloca [4 x i32], align 16
2971 %arrayidx = getelementptr inbounds [4 x i32]* %a, i32 0, i64 0
2972 %0 = load i32* %arrayidx, align 4
2973 ret i32 %0
2974 }
2975
2976 ; test25b: array of [4 x i32]
2977 ; ssp attribute
2978 ; Requires no protector, except for Darwin which _does_ require a protector.
2979 define i32 @test25b() nounwind uwtable ssp {
2980 entry:
2981 ; LINUX-I386-LABEL: test25b:
2982 ; LINUX-I386-NOT: calll __stack_chk_fail
2983 ; LINUX-I386: .cfi_endproc
2984
2985 ; LINUX-X64-LABEL: test25b:
2986 ; LINUX-X64-NOT: callq __stack_chk_fail
2987 ; LINUX-X64: .cfi_endproc
2988
2989 ; LINUX-KERNEL-X64-LABEL: test25b:
2990 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2991 ; LINUX-KERNEL-X64: .cfi_endproc
2992
2993 ; DARWIN-X64-LABEL: test25b:
2994 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2995 ; DARWIN-X64: callq ___stack_chk_fail
2996 %a = alloca [4 x i32], align 16
2997 %arrayidx = getelementptr inbounds [4 x i32]* %a, i32 0, i64 0
2998 %0 = load i32* %arrayidx, align 4
2999 ret i32 %0
3000 }
3001
3002 ; test25c: array of [4 x i32]
3003 ; sspstrong attribute
3004 ; Requires protector.
3005 define i32 @test25c() nounwind uwtable sspstrong {
3006 entry:
3007 ; LINUX-I386-LABEL: test25c:
3008 ; LINUX-I386: mov{{l|q}} %gs:
3009 ; LINUX-I386: calll __stack_chk_fail
3010
3011 ; LINUX-X64-LABEL: test25c:
3012 ; LINUX-X64: mov{{l|q}} %fs:
3013 ; LINUX-X64: callq __stack_chk_fail
3014
3015 ; LINUX-KERNEL-X64-LABEL: test25c:
3016 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
3017 ; LINUX-KERNEL-X64: callq __stack_chk_fail
3018
3019 ; DARWIN-X64-LABEL: test25c:
3020 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
3021 ; DARWIN-X64: callq ___stack_chk_fail
3022 %a = alloca [4 x i32], align 16
3023 %arrayidx = getelementptr inbounds [4 x i32]* %a, i32 0, i64 0
3024 %0 = load i32* %arrayidx, align 4
3025 ret i32 %0
3026 }
3027
3028 ; test25d: array of [4 x i32]
3029 ; sspreq attribute
3030 ; Requires protector.
3031 define i32 @test25d() nounwind uwtable sspreq {
3032 entry:
3033 ; LINUX-I386-LABEL: test25d:
3034 ; LINUX-I386: mov{{l|q}} %gs:
3035 ; LINUX-I386: calll __stack_chk_fail
3036
3037 ; LINUX-X64-LABEL: test25d:
3038 ; LINUX-X64: mov{{l|q}} %fs:
3039 ; LINUX-X64: callq __stack_chk_fail
3040
3041 ; LINUX-KERNEL-X64-LABEL: test25d:
3042 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
3043 ; LINUX-KERNEL-X64: callq __stack_chk_fail
3044
3045 ; DARWIN-X64-LABEL: test25d:
3046 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
3047 ; DARWIN-X64: callq ___stack_chk_fail
3048 %a = alloca [4 x i32], align 16
3049 %arrayidx = getelementptr inbounds [4 x i32]* %a, i32 0, i64 0
3050 %0 = load i32* %arrayidx, align 4
3051 ret i32 %0
3052 }
3053
3054 ; test26: Nested structure, no arrays, no address-of expressions.
3055 ; Verify that the resulting gep-of-gep does not incorrectly trigger
3056 ; a stack protector.
3057 ; ssptrong attribute
3058 ; Requires no protector.
3059 define void @test26() nounwind uwtable sspstrong {
3060 entry:
3061 ; LINUX-I386-LABEL: test26:
3062 ; LINUX-I386-NOT: calll __stack_chk_fail
3063 ; LINUX-I386: .cfi_endproc
3064
3065 ; LINUX-X64-LABEL: test26:
3066 ; LINUX-X64-NOT: callq __stack_chk_fail
3067 ; LINUX-X64: .cfi_endproc
3068
3069 ; LINUX-KERNEL-X64-LABEL: test26:
3070 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
3071 ; LINUX-KERNEL-X64: .cfi_endproc
3072
3073 ; DARWIN-X64-LABEL: test26:
3074 ; DARWIN-X64-NOT: callq ___stack_chk_fail
3075 ; DARWIN-X64: .cfi_endproc
3076 %c = alloca %struct.nest, align 4
3077 %b = getelementptr inbounds %struct.nest* %c, i32 0, i32 1
3078 %_a = getelementptr inbounds %struct.pair* %b, i32 0, i32 0
3079 %0 = load i32* %_a, align 4
3080 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i32 %0)
3081 ret void
3082 }
3083
3084 ; test27: Address-of a structure taken in a function with a loop where
3085 ; the alloca is an incoming value to a PHI node and a use of that PHI
3086 ; node is also an incoming value.
3087 ; Verify that the address-of analysis does not get stuck in infinite
3088 ; recursion when chasing the alloca through the PHI nodes.
3089 ; Requires protector.
3090 define i32 @test27(i32 %arg) nounwind uwtable sspstrong {
3091 bb:
3092 ; LINUX-I386-LABEL: test27:
3093 ; LINUX-I386: mov{{l|q}} %gs:
3094 ; LINUX-I386: calll __stack_chk_fail
3095
3096 ; LINUX-X64-LABEL: test27:
3097 ; LINUX-X64: mov{{l|q}} %fs:
3098 ; LINUX-X64: callq __stack_chk_fail
3099
3100 ; LINUX-KERNEL-X64-LABEL: test27:
3101 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
3102 ; LINUX-KERNEL-X64: callq __stack_chk_fail
3103
3104 ; DARWIN-X64-LABEL: test27:
3105 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
3106 ; DARWIN-X64: callq ___stack_chk_fail
3107 %tmp = alloca %struct.small*, align 8
3108 %tmp1 = call i32 (...)* @dummy(%struct.small** %tmp) nounwind
3109 %tmp2 = load %struct.small** %tmp, align 8
3110 %tmp3 = ptrtoint %struct.small* %tmp2 to i64
3111 %tmp4 = trunc i64 %tmp3 to i32
3112 %tmp5 = icmp sgt i32 %tmp4, 0
3113 br i1 %tmp5, label %bb6, label %bb21
3114
3115 bb6: ; preds = %bb17, %bb
3116 %tmp7 = phi %struct.small* [ %tmp19, %bb17 ], [ %tmp2, %bb ]
3117 %tmp8 = phi i64 [ %tmp20, %bb17 ], [ 1, %bb ]
3118 %tmp9 = phi i32 [ %tmp14, %bb17 ], [ %tmp1, %bb ]
3119 %tmp10 = getelementptr inbounds %struct.small* %tmp7, i64 0, i32 0
3120 %tmp11 = load i8* %tmp10, align 1
3121 %tmp12 = icmp eq i8 %tmp11, 1
3122 %tmp13 = add nsw i32 %tmp9, 8
3123 %tmp14 = select i1 %tmp12, i32 %tmp13, i32 %tmp9
3124 %tmp15 = trunc i64 %tmp8 to i32
3125 %tmp16 = icmp eq i32 %tmp15, %tmp4
3126 br i1 %tmp16, label %bb21, label %bb17
3127
3128 bb17: ; preds = %bb6
3129 %tmp18 = getelementptr inbounds %struct.small** %tmp, i64 %tmp8
3130 %tmp19 = load %struct.small** %tmp18, align 8
3131 %tmp20 = add i64 %tmp8, 1
3132 br label %bb6
3133
3134 bb21: ; preds = %bb6, %bb
3135 %tmp22 = phi i32 [ %tmp1, %bb ], [ %tmp14, %bb6 ]
3136 %tmp23 = call i32 (...)* @dummy(i32 %tmp22) nounwind
3137 ret i32 undef
3138 }
3139
3140 declare double @testi_aux()
3141 declare i8* @strcpy(i8*, i8*)
3142 declare i32 @printf(i8*, ...)
3143 declare void @funcall(i32*)
3144 declare void @funcall2(i32**)
3145 declare void @funfloat(float*)
3146 declare void @funfloat2(float**)
3147 declare void @_Z3exceptPi(i32*)
3148 declare i32 @__gxx_personality_v0(...)
3149 declare i32* @getp()
3150 declare i32 @dummy(...)