Support OpenBSD's native frame protection conventions.
[oota-llvm.git] / test / CodeGen / X86 / stack-protector.ll
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: test1a:
28 ; LINUX-I386-NOT: calll __stack_chk_fail
29 ; LINUX-I386: .cfi_endproc
30
31 ; LINUX-X64: test1a:
32 ; LINUX-X64-NOT: callq __stack_chk_fail
33 ; LINUX-X64: .cfi_endproc
34
35 ; LINUX-KERNEL-X64: test1a:
36 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
37 ; LINUX-KERNEL-X64: .cfi_endproc
38
39 ; DARWIN-X64: 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: test1b:
59 ; LINUX-I386: mov{{l|q}} %gs:
60 ; LINUX-I386: calll __stack_chk_fail
61
62 ; LINUX-X64: test1b:
63 ; LINUX-X64: mov{{l|q}} %fs:
64 ; LINUX-X64: callq __stack_chk_fail
65
66 ; LINUX-KERNEL-X64: test1b:
67 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
68 ; LINUX-KERNEL-X64: callq __stack_chk_fail
69
70 ; DARWIN-X64: test1b:
71 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
72 ; DARWIN-X64: callq ___stack_chk_fail
73
74 ; OPENBSD-AMD64: 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: test1c:
94 ; LINUX-I386: mov{{l|q}} %gs:
95 ; LINUX-I386: calll __stack_chk_fail
96
97 ; LINUX-X64: test1c:
98 ; LINUX-X64: mov{{l|q}} %fs:
99 ; LINUX-X64: callq __stack_chk_fail
100
101 ; LINUX-KERNEL-X64: test1c:
102 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
103 ; LINUX-KERNEL-X64: callq __stack_chk_fail
104
105 ; DARWIN-X64: 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: test1d:
125 ; LINUX-I386: mov{{l|q}} %gs:
126 ; LINUX-I386: calll __stack_chk_fail
127
128 ; LINUX-X64: test1d:
129 ; LINUX-X64: mov{{l|q}} %fs:
130 ; LINUX-X64: callq __stack_chk_fail
131
132 ; LINUX-KERNEL-X64: test1d:
133 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
134 ; LINUX-KERNEL-X64: callq __stack_chk_fail
135
136 ; DARWIN-X64: 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: test2a:
156 ; LINUX-I386-NOT: calll __stack_chk_fail
157 ; LINUX-I386: .cfi_endproc
158
159 ; LINUX-X64: test2a:
160 ; LINUX-X64-NOT: callq __stack_chk_fail
161 ; LINUX-X64: .cfi_endproc
162
163 ; LINUX-KERNEL-X64: test2a:
164 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
165 ; LINUX-KERNEL-X64: .cfi_endproc
166
167 ; DARWIN-X64: 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: test2b:
189 ; LINUX-I386: mov{{l|q}} %gs:
190 ; LINUX-I386: calll __stack_chk_fail
191
192 ; LINUX-X64: test2b:
193 ; LINUX-X64: mov{{l|q}} %fs:
194 ; LINUX-X64: callq __stack_chk_fail
195
196 ; LINUX-KERNEL-X64: test2b:
197 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
198 ; LINUX-KERNEL-X64: callq __stack_chk_fail
199
200 ; DARWIN-X64: 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: test2c:
222 ; LINUX-I386: mov{{l|q}} %gs:
223 ; LINUX-I386: calll __stack_chk_fail
224
225 ; LINUX-X64: test2c:
226 ; LINUX-X64: mov{{l|q}} %fs:
227 ; LINUX-X64: callq __stack_chk_fail
228
229 ; LINUX-KERNEL-X64: test2c:
230 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
231 ; LINUX-KERNEL-X64: callq __stack_chk_fail
232
233 ; DARWIN-X64: 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: test2d:
255 ; LINUX-I386: mov{{l|q}} %gs:
256 ; LINUX-I386: calll __stack_chk_fail
257
258 ; LINUX-X64: test2d:
259 ; LINUX-X64: mov{{l|q}} %fs:
260 ; LINUX-X64: callq __stack_chk_fail
261
262 ; LINUX-KERNEL-X64: test2d:
263 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
264 ; LINUX-KERNEL-X64: callq __stack_chk_fail
265
266 ; DARWIN-X64: 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: test3a:
288 ; LINUX-I386-NOT: calll __stack_chk_fail
289 ; LINUX-I386: .cfi_endproc
290
291 ; LINUX-X64: test3a:
292 ; LINUX-X64-NOT: callq __stack_chk_fail
293 ; LINUX-X64: .cfi_endproc
294
295 ; LINUX-KERNEL-X64: test3a:
296 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
297 ; LINUX-KERNEL-X64: .cfi_endproc
298
299 ; DARWIN-X64: 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: test3b:
319 ; LINUX-I386-NOT: calll __stack_chk_fail
320 ; LINUX-I386: .cfi_endproc
321
322 ; LINUX-X64: test3b:
323 ; LINUX-X64-NOT: callq __stack_chk_fail
324 ; LINUX-X64: .cfi_endproc
325
326 ; LINUX-KERNEL-X64: test3b:
327 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
328 ; LINUX-KERNEL-X64: .cfi_endproc
329
330 ; DARWIN-X64: 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: test3c:
350 ; LINUX-I386: mov{{l|q}} %gs:
351 ; LINUX-I386: calll __stack_chk_fail
352
353 ; LINUX-X64: test3c:
354 ; LINUX-X64: mov{{l|q}} %fs:
355 ; LINUX-X64: callq __stack_chk_fail
356
357 ; LINUX-KERNEL-X64: test3c:
358 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
359 ; LINUX-KERNEL-X64: callq __stack_chk_fail
360
361 ; DARWIN-X64: 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: test3d:
381 ; LINUX-I386: mov{{l|q}} %gs:
382 ; LINUX-I386: calll __stack_chk_fail
383
384 ; LINUX-X64: test3d:
385 ; LINUX-X64: mov{{l|q}} %fs:
386 ; LINUX-X64: callq __stack_chk_fail
387
388 ; LINUX-KERNEL-X64: test3d:
389 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
390 ; LINUX-KERNEL-X64: callq __stack_chk_fail
391
392 ; DARWIN-X64: 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: test4a:
412 ; LINUX-I386-NOT: calll __stack_chk_fail
413 ; LINUX-I386: .cfi_endproc
414
415 ; LINUX-X64: test4a:
416 ; LINUX-X64-NOT: callq __stack_chk_fail
417 ; LINUX-X64: .cfi_endproc
418
419 ; LINUX-KERNEL-X64: test4a:
420 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
421 ; LINUX-KERNEL-X64: .cfi_endproc
422
423 ; DARWIN-X64: 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: test4b:
445 ; LINUX-I386-NOT: calll __stack_chk_fail
446 ; LINUX-I386: .cfi_endproc
447
448 ; LINUX-X64: test4b:
449 ; LINUX-X64-NOT: callq __stack_chk_fail
450 ; LINUX-X64: .cfi_endproc
451
452 ; LINUX-KERNEL-X64: test4b:
453 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
454 ; LINUX-KERNEL-X64: .cfi_endproc
455
456 ; DARWIN-X64: 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: test4c:
478 ; LINUX-I386: mov{{l|q}} %gs:
479 ; LINUX-I386: calll __stack_chk_fail
480
481 ; LINUX-X64: test4c:
482 ; LINUX-X64: mov{{l|q}} %fs:
483 ; LINUX-X64: callq __stack_chk_fail
484
485 ; LINUX-KERNEL-X64: test4c:
486 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
487 ; LINUX-KERNEL-X64: callq __stack_chk_fail
488
489 ; DARWIN-X64: 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: test4d:
511 ; LINUX-I386: mov{{l|q}} %gs:
512 ; LINUX-I386: calll __stack_chk_fail
513
514 ; LINUX-X64: test4d:
515 ; LINUX-X64: mov{{l|q}} %fs:
516 ; LINUX-X64: callq __stack_chk_fail
517
518 ; LINUX-KERNEL-X64: test4d:
519 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
520 ; LINUX-KERNEL-X64: callq __stack_chk_fail
521
522 ; DARWIN-X64: 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: test5a:
544 ; LINUX-I386-NOT: calll __stack_chk_fail
545 ; LINUX-I386: .cfi_endproc
546
547 ; LINUX-X64: test5a:
548 ; LINUX-X64-NOT: callq __stack_chk_fail
549 ; LINUX-X64: .cfi_endproc
550
551 ; LINUX-KERNEL-X64: test5a:
552 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
553 ; LINUX-KERNEL-X64: .cfi_endproc
554
555 ; DARWIN-X64: 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: test5b:
571 ; LINUX-I386-NOT: calll __stack_chk_fail
572 ; LINUX-I386: .cfi_endproc
573
574 ; LINUX-X64: test5b:
575 ; LINUX-X64-NOT: callq __stack_chk_fail
576 ; LINUX-X64: .cfi_endproc
577
578 ; LINUX-KERNEL-X64: test5b:
579 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
580 ; LINUX-KERNEL-X64: .cfi_endproc
581
582 ; DARWIN-X64: 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: test5c:
598 ; LINUX-I386-NOT: calll __stack_chk_fail
599 ; LINUX-I386: .cfi_endproc
600
601 ; LINUX-X64: test5c:
602 ; LINUX-X64-NOT: callq __stack_chk_fail
603 ; LINUX-X64: .cfi_endproc
604
605 ; LINUX-KERNEL-X64: test5c:
606 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
607 ; LINUX-KERNEL-X64: .cfi_endproc
608
609 ; DARWIN-X64: 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: test5d:
625 ; LINUX-I386: mov{{l|q}} %gs:
626 ; LINUX-I386: calll __stack_chk_fail
627
628 ; LINUX-X64: test5d:
629 ; LINUX-X64: mov{{l|q}} %fs:
630 ; LINUX-X64: callq __stack_chk_fail
631
632 ; LINUX-KERNEL-X64: test5d:
633 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
634 ; LINUX-KERNEL-X64: callq __stack_chk_fail
635
636 ; DARWIN-X64: 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: test6a:
652 ; LINUX-I386-NOT: calll __stack_chk_fail
653 ; LINUX-I386: .cfi_endproc
654
655 ; LINUX-X64: test6a:
656 ; LINUX-X64-NOT: callq __stack_chk_fail
657 ; LINUX-X64: .cfi_endproc
658
659 ; LINUX-KERNEL-X64: test6a:
660 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
661 ; LINUX-KERNEL-X64: .cfi_endproc
662
663 ; DARWIN-X64: 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: test6b:
683 ; LINUX-I386-NOT: calll __stack_chk_fail
684 ; LINUX-I386: .cfi_endproc
685
686 ; LINUX-X64: test6b:
687 ; LINUX-X64-NOT: callq __stack_chk_fail
688 ; LINUX-X64: .cfi_endproc
689
690 ; LINUX-KERNEL-X64: test6b:
691 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
692 ; LINUX-KERNEL-X64: .cfi_endproc
693
694 ; DARWIN-X64: 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: test6c:
714 ; LINUX-I386: mov{{l|q}} %gs:
715 ; LINUX-I386: calll __stack_chk_fail
716
717 ; LINUX-X64: test6c:
718 ; LINUX-X64: mov{{l|q}} %fs:
719 ; LINUX-X64: callq __stack_chk_fail
720
721 ; LINUX-KERNEL-X64: test6c:
722 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
723 ; LINUX-KERNEL-X64: callq __stack_chk_fail
724
725 ; DARWIN-X64: 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: test6d:
745 ; LINUX-I386: mov{{l|q}} %gs:
746 ; LINUX-I386: calll __stack_chk_fail
747
748 ; LINUX-X64: test6d:
749 ; LINUX-X64: mov{{l|q}} %fs:
750 ; LINUX-X64: callq __stack_chk_fail
751
752 ; LINUX-KERNEL-X64: test6d:
753 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
754 ; LINUX-KERNEL-X64: callq __stack_chk_fail
755
756 ; DARWIN-X64: 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: test7a:
776 ; LINUX-I386-NOT: calll __stack_chk_fail
777 ; LINUX-I386: .cfi_endproc
778
779 ; LINUX-X64: test7a:
780 ; LINUX-X64-NOT: callq __stack_chk_fail
781 ; LINUX-X64: .cfi_endproc
782
783 ; LINUX-KERNEL-X64: test7a:
784 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
785 ; LINUX-KERNEL-X64: .cfi_endproc
786
787 ; DARWIN-X64: 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: test7b:
802 ; LINUX-I386-NOT: calll __stack_chk_fail
803 ; LINUX-I386: .cfi_endproc
804
805 ; LINUX-X64: test7b:
806 ; LINUX-X64-NOT: callq __stack_chk_fail
807 ; LINUX-X64: .cfi_endproc
808
809 ; LINUX-KERNEL-X64: test7b:
810 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
811 ; LINUX-KERNEL-X64: .cfi_endproc
812
813 ; DARWIN-X64: 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: test7c:
828 ; LINUX-I386: mov{{l|q}} %gs:
829 ; LINUX-I386: calll __stack_chk_fail
830
831 ; LINUX-X64: test7c:
832 ; LINUX-X64: mov{{l|q}} %fs:
833 ; LINUX-X64: callq __stack_chk_fail
834
835 ; LINUX-KERNEL-X64: test7c:
836 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
837 ; LINUX-KERNEL-X64: callq __stack_chk_fail
838
839 ; DARWIN-X64: 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: test7d:
854 ; LINUX-I386: mov{{l|q}} %gs:
855 ; LINUX-I386: calll __stack_chk_fail
856
857 ; LINUX-X64: test7d:
858 ; LINUX-X64: mov{{l|q}} %fs:
859 ; LINUX-X64: callq __stack_chk_fail
860
861 ; LINUX-KERNEL-X64: test7d:
862 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
863 ; LINUX-KERNEL-X64: callq __stack_chk_fail
864
865 ; DARWIN-X64: 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: test8a:
880 ; LINUX-I386-NOT: calll __stack_chk_fail
881 ; LINUX-I386: .cfi_endproc
882
883 ; LINUX-X64: test8a:
884 ; LINUX-X64-NOT: callq __stack_chk_fail
885 ; LINUX-X64: .cfi_endproc
886
887 ; LINUX-KERNEL-X64: test8a:
888 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
889 ; LINUX-KERNEL-X64: .cfi_endproc
890
891 ; DARWIN-X64: 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: test8b:
905 ; LINUX-I386-NOT: calll __stack_chk_fail
906 ; LINUX-I386: .cfi_endproc
907
908 ; LINUX-X64: test8b:
909 ; LINUX-X64-NOT: callq __stack_chk_fail
910 ; LINUX-X64: .cfi_endproc
911
912 ; LINUX-KERNEL-X64: test8b:
913 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
914 ; LINUX-KERNEL-X64: .cfi_endproc
915
916 ; DARWIN-X64: 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: test8c:
930 ; LINUX-I386: mov{{l|q}} %gs:
931 ; LINUX-I386: calll __stack_chk_fail
932
933 ; LINUX-X64: test8c:
934 ; LINUX-X64: mov{{l|q}} %fs:
935 ; LINUX-X64: callq __stack_chk_fail
936
937 ; LINUX-KERNEL-X64: test8c:
938 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
939 ; LINUX-KERNEL-X64: callq __stack_chk_fail
940
941 ; DARWIN-X64: 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: test8d:
955 ; LINUX-I386: mov{{l|q}} %gs:
956 ; LINUX-I386: calll __stack_chk_fail
957
958 ; LINUX-X64: test8d:
959 ; LINUX-X64: mov{{l|q}} %fs:
960 ; LINUX-X64: callq __stack_chk_fail
961
962 ; LINUX-KERNEL-X64: test8d:
963 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
964 ; LINUX-KERNEL-X64: callq __stack_chk_fail
965
966 ; DARWIN-X64: 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: test9a:
980 ; LINUX-I386-NOT: calll __stack_chk_fail
981 ; LINUX-I386: .cfi_endproc
982
983 ; LINUX-X64: test9a:
984 ; LINUX-X64-NOT: callq __stack_chk_fail
985 ; LINUX-X64: .cfi_endproc
986
987 ; LINUX-KERNEL-X64: test9a:
988 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
989 ; LINUX-KERNEL-X64: .cfi_endproc
990
991 ; DARWIN-X64: 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: test9b:
1009 ; LINUX-I386-NOT: calll __stack_chk_fail
1010 ; LINUX-I386: .cfi_endproc
1011
1012 ; LINUX-X64: test9b:
1013 ; LINUX-X64-NOT: callq __stack_chk_fail
1014 ; LINUX-X64: .cfi_endproc
1015
1016 ; LINUX-KERNEL-X64: test9b:
1017 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1018 ; LINUX-KERNEL-X64: .cfi_endproc
1019
1020 ; DARWIN-X64: 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: test9c:
1038 ; LINUX-I386: mov{{l|q}} %gs:
1039 ; LINUX-I386: calll __stack_chk_fail
1040
1041 ; LINUX-X64: test9c:
1042 ; LINUX-X64: mov{{l|q}} %fs:
1043 ; LINUX-X64: callq __stack_chk_fail
1044
1045 ; LINUX-KERNEL-X64: test9c:
1046 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1047 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1048
1049 ; DARWIN-X64: 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: test9d:
1067 ; LINUX-I386: mov{{l|q}} %gs:
1068 ; LINUX-I386: calll __stack_chk_fail
1069
1070 ; LINUX-X64: test9d:
1071 ; LINUX-X64: mov{{l|q}} %fs:
1072 ; LINUX-X64: callq __stack_chk_fail
1073
1074 ; LINUX-KERNEL-X64: test9d:
1075 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1076 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1077
1078 ; DARWIN-X64: 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: test10a:
1096 ; LINUX-I386-NOT: calll __stack_chk_fail
1097 ; LINUX-I386: .cfi_endproc
1098
1099 ; LINUX-X64: test10a:
1100 ; LINUX-X64-NOT: callq __stack_chk_fail
1101 ; LINUX-X64: .cfi_endproc
1102
1103 ; LINUX-KERNEL-X64: test10a:
1104 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1105 ; LINUX-KERNEL-X64: .cfi_endproc
1106
1107 ; DARWIN-X64: 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: test10b:
1140 ; LINUX-I386-NOT: calll __stack_chk_fail
1141 ; LINUX-I386: .cfi_endproc
1142
1143 ; LINUX-X64: test10b:
1144 ; LINUX-X64-NOT: callq __stack_chk_fail
1145 ; LINUX-X64: .cfi_endproc
1146
1147 ; LINUX-KERNEL-X64: test10b:
1148 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1149 ; LINUX-KERNEL-X64: .cfi_endproc
1150
1151 ; DARWIN-X64: 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: test10c:
1184 ; LINUX-I386: mov{{l|q}} %gs:
1185 ; LINUX-I386: calll __stack_chk_fail
1186
1187 ; LINUX-X64: test10c:
1188 ; LINUX-X64: mov{{l|q}} %fs:
1189 ; LINUX-X64: callq __stack_chk_fail
1190
1191 ; LINUX-KERNEL-X64: test10c:
1192 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1193 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1194
1195 ; DARWIN-X64: 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: test10d:
1228 ; LINUX-I386: mov{{l|q}} %gs:
1229 ; LINUX-I386: calll __stack_chk_fail
1230
1231 ; LINUX-X64: test10d:
1232 ; LINUX-X64: mov{{l|q}} %fs:
1233 ; LINUX-X64: callq __stack_chk_fail
1234
1235 ; LINUX-KERNEL-X64: test10d:
1236 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1237 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1238
1239 ; DARWIN-X64: 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: test11a:
1272 ; LINUX-I386-NOT: calll __stack_chk_fail
1273 ; LINUX-I386: .cfi_endproc
1274
1275 ; LINUX-X64: test11a:
1276 ; LINUX-X64-NOT: callq __stack_chk_fail
1277 ; LINUX-X64: .cfi_endproc
1278
1279 ; LINUX-KERNEL-X64: test11a:
1280 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1281 ; LINUX-KERNEL-X64: .cfi_endproc
1282
1283 ; DARWIN-X64: 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: test11b:
1301 ; LINUX-I386-NOT: calll __stack_chk_fail
1302 ; LINUX-I386: .cfi_endproc
1303
1304 ; LINUX-X64: test11b:
1305 ; LINUX-X64-NOT: callq __stack_chk_fail
1306 ; LINUX-X64: .cfi_endproc
1307
1308 ; LINUX-KERNEL-X64: test11b:
1309 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1310 ; LINUX-KERNEL-X64: .cfi_endproc
1311
1312 ; DARWIN-X64: 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: test11c:
1330 ; LINUX-I386: mov{{l|q}} %gs:
1331 ; LINUX-I386: calll __stack_chk_fail
1332
1333 ; LINUX-X64: test11c:
1334 ; LINUX-X64: mov{{l|q}} %fs:
1335 ; LINUX-X64: callq __stack_chk_fail
1336
1337 ; LINUX-KERNEL-X64: test11c:
1338 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1339 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1340
1341 ; DARWIN-X64: 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: test11d:
1359 ; LINUX-I386: mov{{l|q}} %gs:
1360 ; LINUX-I386: calll __stack_chk_fail
1361
1362 ; LINUX-X64: test11d:
1363 ; LINUX-X64: mov{{l|q}} %fs:
1364 ; LINUX-X64: callq __stack_chk_fail
1365
1366 ; LINUX-KERNEL-X64: test11d:
1367 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1368 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1369
1370 ; DARWIN-X64: 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: test12a:
1388 ; LINUX-I386-NOT: calll __stack_chk_fail
1389 ; LINUX-I386: .cfi_endproc
1390
1391 ; LINUX-X64: test12a:
1392 ; LINUX-X64-NOT: callq __stack_chk_fail
1393 ; LINUX-X64: .cfi_endproc
1394
1395 ; LINUX-KERNEL-X64: test12a:
1396 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1397 ; LINUX-KERNEL-X64: .cfi_endproc
1398
1399 ; DARWIN-X64: 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: test12b:
1416 ; LINUX-I386-NOT: calll __stack_chk_fail
1417 ; LINUX-I386: .cfi_endproc
1418
1419 ; LINUX-X64: test12b:
1420 ; LINUX-X64-NOT: callq __stack_chk_fail
1421 ; LINUX-X64: .cfi_endproc
1422
1423 ; LINUX-KERNEL-X64: test12b:
1424 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1425 ; LINUX-KERNEL-X64: .cfi_endproc
1426
1427 ; DARWIN-X64: 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: test12c:
1444 ; LINUX-I386: mov{{l|q}} %gs:
1445 ; LINUX-I386: calll __stack_chk_fail
1446
1447 ; LINUX-X64: test12c:
1448 ; LINUX-X64: mov{{l|q}} %fs:
1449 ; LINUX-X64: callq __stack_chk_fail
1450
1451 ; LINUX-KERNEL-X64: test12c:
1452 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1453 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1454
1455 ; DARWIN-X64: 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: test12d:
1472 ; LINUX-I386: mov{{l|q}} %gs:
1473 ; LINUX-I386: calll __stack_chk_fail
1474
1475 ; LINUX-X64: test12d:
1476 ; LINUX-X64: mov{{l|q}} %fs:
1477 ; LINUX-X64: callq __stack_chk_fail
1478
1479 ; LINUX-KERNEL-X64: test12d:
1480 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1481 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1482
1483 ; DARWIN-X64: 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: test13a:
1500 ; LINUX-I386-NOT: calll __stack_chk_fail
1501 ; LINUX-I386: .cfi_endproc
1502
1503 ; LINUX-X64: test13a:
1504 ; LINUX-X64-NOT: callq __stack_chk_fail
1505 ; LINUX-X64: .cfi_endproc
1506
1507 ; LINUX-KERNEL-X64: test13a:
1508 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1509 ; LINUX-KERNEL-X64: .cfi_endproc
1510
1511 ; DARWIN-X64: 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: test13b:
1526 ; LINUX-I386-NOT: calll __stack_chk_fail
1527 ; LINUX-I386: .cfi_endproc
1528
1529 ; LINUX-X64: test13b:
1530 ; LINUX-X64-NOT: callq __stack_chk_fail
1531 ; LINUX-X64: .cfi_endproc
1532
1533 ; LINUX-KERNEL-X64: test13b:
1534 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1535 ; LINUX-KERNEL-X64: .cfi_endproc
1536
1537 ; DARWIN-X64: 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: test13c:
1552 ; LINUX-I386: mov{{l|q}} %gs:
1553 ; LINUX-I386: calll __stack_chk_fail
1554
1555 ; LINUX-X64: test13c:
1556 ; LINUX-X64: mov{{l|q}} %fs:
1557 ; LINUX-X64: callq __stack_chk_fail
1558
1559 ; LINUX-KERNEL-X64: test13c:
1560 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1561 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1562
1563 ; DARWIN-X64: 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: test13d:
1578 ; LINUX-I386: mov{{l|q}} %gs:
1579 ; LINUX-I386: calll __stack_chk_fail
1580
1581 ; LINUX-X64: test13d:
1582 ; LINUX-X64: mov{{l|q}} %fs:
1583 ; LINUX-X64: callq __stack_chk_fail
1584
1585 ; LINUX-KERNEL-X64: test13d:
1586 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1587 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1588
1589 ; DARWIN-X64: 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: test14a:
1604 ; LINUX-I386-NOT: calll __stack_chk_fail
1605 ; LINUX-I386: .cfi_endproc
1606
1607 ; LINUX-X64: test14a:
1608 ; LINUX-X64-NOT: callq __stack_chk_fail
1609 ; LINUX-X64: .cfi_endproc
1610
1611 ; LINUX-KERNEL-X64: test14a:
1612 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1613 ; LINUX-KERNEL-X64: .cfi_endproc
1614
1615 ; DARWIN-X64: 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: test14b:
1630 ; LINUX-I386-NOT: calll __stack_chk_fail
1631 ; LINUX-I386: .cfi_endproc
1632
1633 ; LINUX-X64: test14b:
1634 ; LINUX-X64-NOT: callq __stack_chk_fail
1635 ; LINUX-X64: .cfi_endproc
1636
1637 ; LINUX-KERNEL-X64: test14b:
1638 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1639 ; LINUX-KERNEL-X64: .cfi_endproc
1640
1641 ; DARWIN-X64: 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: test14c:
1656 ; LINUX-I386: mov{{l|q}} %gs:
1657 ; LINUX-I386: calll __stack_chk_fail
1658
1659 ; LINUX-X64: test14c:
1660 ; LINUX-X64: mov{{l|q}} %fs:
1661 ; LINUX-X64: callq __stack_chk_fail
1662
1663 ; LINUX-KERNEL-X64: test14c:
1664 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1665 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1666
1667 ; DARWIN-X64: 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: test14d:
1682 ; LINUX-I386: mov{{l|q}} %gs:
1683 ; LINUX-I386: calll __stack_chk_fail
1684
1685 ; LINUX-X64: test14d:
1686 ; LINUX-X64: mov{{l|q}} %fs:
1687 ; LINUX-X64: callq __stack_chk_fail
1688
1689 ; LINUX-KERNEL-X64: test14d:
1690 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1691 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1692
1693 ; DARWIN-X64: 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: test15a:
1709 ; LINUX-I386-NOT: calll __stack_chk_fail
1710 ; LINUX-I386: .cfi_endproc
1711
1712 ; LINUX-X64: test15a:
1713 ; LINUX-X64-NOT: callq __stack_chk_fail
1714 ; LINUX-X64: .cfi_endproc
1715
1716 ; LINUX-KERNEL-X64: test15a:
1717 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1718 ; LINUX-KERNEL-X64: .cfi_endproc
1719
1720 ; DARWIN-X64: 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: test15b:
1740 ; LINUX-I386-NOT: calll __stack_chk_fail
1741 ; LINUX-I386: .cfi_endproc
1742
1743 ; LINUX-X64: test15b:
1744 ; LINUX-X64-NOT: callq __stack_chk_fail
1745 ; LINUX-X64: .cfi_endproc
1746
1747 ; LINUX-KERNEL-X64: test15b:
1748 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1749 ; LINUX-KERNEL-X64: .cfi_endproc
1750
1751 ; DARWIN-X64: 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: test15c:
1771 ; LINUX-I386: mov{{l|q}} %gs:
1772 ; LINUX-I386: calll __stack_chk_fail
1773
1774 ; LINUX-X64: test15c:
1775 ; LINUX-X64: mov{{l|q}} %fs:
1776 ; LINUX-X64: callq __stack_chk_fail
1777
1778 ; LINUX-KERNEL-X64: test15c:
1779 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1780 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1781
1782 ; DARWIN-X64: 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: test15d:
1802 ; LINUX-I386: mov{{l|q}} %gs:
1803 ; LINUX-I386: calll __stack_chk_fail
1804
1805 ; LINUX-X64: test15d:
1806 ; LINUX-X64: mov{{l|q}} %fs:
1807 ; LINUX-X64: callq __stack_chk_fail
1808
1809 ; LINUX-KERNEL-X64: test15d:
1810 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1811 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1812
1813 ; DARWIN-X64: 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: test16a:
1833 ; LINUX-I386-NOT: calll __stack_chk_fail
1834 ; LINUX-I386: .cfi_endproc
1835
1836 ; LINUX-X64: test16a:
1837 ; LINUX-X64-NOT: callq __stack_chk_fail
1838 ; LINUX-X64: .cfi_endproc
1839
1840 ; LINUX-KERNEL-X64: test16a:
1841 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1842 ; LINUX-KERNEL-X64: .cfi_endproc
1843
1844 ; DARWIN-X64: 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: test16b:
1861 ; LINUX-I386-NOT: calll __stack_chk_fail
1862 ; LINUX-I386: .cfi_endproc
1863
1864 ; LINUX-X64: test16b:
1865 ; LINUX-X64-NOT: callq __stack_chk_fail
1866 ; LINUX-X64: .cfi_endproc
1867
1868 ; LINUX-KERNEL-X64: test16b:
1869 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1870 ; LINUX-KERNEL-X64: .cfi_endproc
1871
1872 ; DARWIN-X64: 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: test16c:
1889 ; LINUX-I386: mov{{l|q}} %gs:
1890 ; LINUX-I386: calll __stack_chk_fail
1891
1892 ; LINUX-X64: test16c:
1893 ; LINUX-X64: mov{{l|q}} %fs:
1894 ; LINUX-X64: callq __stack_chk_fail
1895
1896 ; LINUX-KERNEL-X64: test16c:
1897 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1898 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1899
1900 ; DARWIN-X64: 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: test16d:
1917 ; LINUX-I386: mov{{l|q}} %gs:
1918 ; LINUX-I386: calll __stack_chk_fail
1919
1920 ; LINUX-X64: test16d:
1921 ; LINUX-X64: mov{{l|q}} %fs:
1922 ; LINUX-X64: callq __stack_chk_fail
1923
1924 ; LINUX-KERNEL-X64: test16d:
1925 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
1926 ; LINUX-KERNEL-X64: callq __stack_chk_fail
1927
1928 ; DARWIN-X64: 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: test17a:
1944 ; LINUX-I386-NOT: calll __stack_chk_fail
1945 ; LINUX-I386: .cfi_endproc
1946
1947 ; LINUX-X64: test17a:
1948 ; LINUX-X64-NOT: callq __stack_chk_fail
1949 ; LINUX-X64: .cfi_endproc
1950
1951 ; LINUX-KERNEL-X64: test17a:
1952 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1953 ; LINUX-KERNEL-X64: .cfi_endproc
1954
1955 ; DARWIN-X64: 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: test17b:
1971 ; LINUX-I386-NOT: calll __stack_chk_fail
1972 ; LINUX-I386: .cfi_endproc
1973
1974 ; LINUX-X64: test17b:
1975 ; LINUX-X64-NOT: callq __stack_chk_fail
1976 ; LINUX-X64: .cfi_endproc
1977
1978 ; LINUX-KERNEL-X64: test17b:
1979 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
1980 ; LINUX-KERNEL-X64: .cfi_endproc
1981
1982 ; DARWIN-X64: 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: test17c:
1998 ; LINUX-I386: mov{{l|q}} %gs:
1999 ; LINUX-I386: calll __stack_chk_fail
2000
2001 ; LINUX-X64: test17c:
2002 ; LINUX-X64: mov{{l|q}} %fs:
2003 ; LINUX-X64: callq __stack_chk_fail
2004
2005 ; LINUX-KERNEL-X64: test17c:
2006 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2007 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2008
2009 ; DARWIN-X64: 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: test17d:
2025 ; LINUX-I386: mov{{l|q}} %gs:
2026 ; LINUX-I386: calll __stack_chk_fail
2027
2028 ; LINUX-X64: test17d:
2029 ; LINUX-X64: mov{{l|q}} %fs:
2030 ; LINUX-X64: callq __stack_chk_fail
2031
2032 ; LINUX-KERNEL-X64: test17d:
2033 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2034 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2035
2036 ; DARWIN-X64: 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: test18a:
2052 ; LINUX-I386-NOT: calll __stack_chk_fail
2053 ; LINUX-I386: .cfi_endproc
2054
2055 ; LINUX-X64: test18a:
2056 ; LINUX-X64-NOT: callq __stack_chk_fail
2057 ; LINUX-X64: .cfi_endproc
2058
2059 ; LINUX-KERNEL-X64: test18a:
2060 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2061 ; LINUX-KERNEL-X64: .cfi_endproc
2062
2063 ; DARWIN-X64: 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: test18b:
2088 ; LINUX-I386-NOT: calll __stack_chk_fail
2089 ; LINUX-I386: .cfi_endproc
2090
2091 ; LINUX-X64: test18b:
2092 ; LINUX-X64-NOT: callq __stack_chk_fail
2093 ; LINUX-X64: .cfi_endproc
2094
2095 ; LINUX-KERNEL-X64: test18b:
2096 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2097 ; LINUX-KERNEL-X64: .cfi_endproc
2098
2099 ; DARWIN-X64: 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: test18c:
2124 ; LINUX-I386: mov{{l|q}} %gs:
2125 ; LINUX-I386: calll __stack_chk_fail
2126
2127 ; LINUX-X64: test18c:
2128 ; LINUX-X64: mov{{l|q}} %fs:
2129 ; LINUX-X64: callq __stack_chk_fail
2130
2131 ; LINUX-KERNEL-X64: test18c:
2132 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2133 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2134
2135 ; DARWIN-X64: 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: test18d:
2160 ; LINUX-I386: mov{{l|q}} %gs:
2161 ; LINUX-I386: calll __stack_chk_fail
2162
2163 ; LINUX-X64: test18d:
2164 ; LINUX-X64: mov{{l|q}} %fs:
2165 ; LINUX-X64: callq __stack_chk_fail
2166
2167 ; LINUX-KERNEL-X64: test18d:
2168 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2169 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2170
2171 ; DARWIN-X64: 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: test19a:
2197 ; LINUX-I386-NOT: calll __stack_chk_fail
2198 ; LINUX-I386: .cfi_endproc
2199
2200 ; LINUX-X64: test19a:
2201 ; LINUX-X64-NOT: callq __stack_chk_fail
2202 ; LINUX-X64: .cfi_endproc
2203
2204 ; LINUX-KERNEL-X64: test19a:
2205 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2206 ; LINUX-KERNEL-X64: .cfi_endproc
2207
2208 ; DARWIN-X64: 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: test19b:
2236 ; LINUX-I386-NOT: calll __stack_chk_fail
2237 ; LINUX-I386: .cfi_endproc
2238
2239 ; LINUX-X64: test19b:
2240 ; LINUX-X64-NOT: callq __stack_chk_fail
2241 ; LINUX-X64: .cfi_endproc
2242
2243 ; LINUX-KERNEL-X64: test19b:
2244 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2245 ; LINUX-KERNEL-X64: .cfi_endproc
2246
2247 ; DARWIN-X64: 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: test19c:
2275 ; LINUX-I386: mov{{l|q}} %gs:
2276 ; LINUX-I386: calll __stack_chk_fail
2277
2278 ; LINUX-X64: test19c:
2279 ; LINUX-X64: mov{{l|q}} %fs:
2280 ; LINUX-X64: callq __stack_chk_fail
2281
2282 ; LINUX-KERNEL-X64: test19c:
2283 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2284 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2285
2286 ; DARWIN-X64: 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: test19d:
2314 ; LINUX-I386: mov{{l|q}} %gs:
2315 ; LINUX-I386: calll __stack_chk_fail
2316
2317 ; LINUX-X64: test19d:
2318 ; LINUX-X64: mov{{l|q}} %fs:
2319 ; LINUX-X64: callq __stack_chk_fail
2320
2321 ; LINUX-KERNEL-X64: test19d:
2322 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2323 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2324
2325 ; DARWIN-X64: test19d:
2326 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2327 ; DARWIN-X64: callq ___stack_chk_fail
2328   %c = alloca %struct.pair, align 4
2329   %exn.slot = alloca i8*
2330   %ehselector.slot = alloca i32
2331   %a = getelementptr inbounds %struct.pair* %c, i32 0, i32 0
2332   store i32 0, i32* %a, align 4
2333   %a1 = getelementptr inbounds %struct.pair* %c, i32 0, i32 0
2334   invoke void @_Z3exceptPi(i32* %a1)
2335           to label %invoke.cont unwind label %lpad
2336
2337 invoke.cont:
2338   ret i32 0
2339
2340 lpad:
2341   %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
2342           catch i8* null
2343   ret i32 0
2344 }
2345
2346 ; test20a: Addr-of a pointer
2347 ;          no ssp attribute
2348 ; Requires no protector.
2349 define void @test20a() nounwind uwtable {
2350 entry:
2351 ; LINUX-I386: test20a:
2352 ; LINUX-I386-NOT: calll __stack_chk_fail
2353 ; LINUX-I386: .cfi_endproc
2354
2355 ; LINUX-X64: test20a:
2356 ; LINUX-X64-NOT: callq __stack_chk_fail
2357 ; LINUX-X64: .cfi_endproc
2358
2359 ; LINUX-KERNEL-X64: test20a:
2360 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2361 ; LINUX-KERNEL-X64: .cfi_endproc
2362
2363 ; DARWIN-X64: test20a:
2364 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2365 ; DARWIN-X64: .cfi_endproc
2366   %a = alloca i32*, align 8
2367   %b = alloca i32**, align 8
2368   %call = call i32* @getp()
2369   store i32* %call, i32** %a, align 8
2370   store i32** %a, i32*** %b, align 8
2371   %0 = load i32*** %b, align 8
2372   call void @funcall2(i32** %0)
2373   ret void
2374 }
2375
2376 ; test20b: Addr-of a pointer
2377 ;          ssp attribute
2378 ; Requires no protector.
2379 define void @test20b() nounwind uwtable ssp {
2380 entry:
2381 ; LINUX-I386: test20b:
2382 ; LINUX-I386-NOT: calll __stack_chk_fail
2383 ; LINUX-I386: .cfi_endproc
2384
2385 ; LINUX-X64: test20b:
2386 ; LINUX-X64-NOT: callq __stack_chk_fail
2387 ; LINUX-X64: .cfi_endproc
2388
2389 ; LINUX-KERNEL-X64: test20b:
2390 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2391 ; LINUX-KERNEL-X64: .cfi_endproc
2392
2393 ; DARWIN-X64: test20b:
2394 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2395 ; DARWIN-X64: .cfi_endproc
2396   %a = alloca i32*, align 8
2397   %b = alloca i32**, align 8
2398   %call = call i32* @getp()
2399   store i32* %call, i32** %a, align 8
2400   store i32** %a, i32*** %b, align 8
2401   %0 = load i32*** %b, align 8
2402   call void @funcall2(i32** %0)
2403   ret void
2404 }
2405
2406 ; test20c: Addr-of a pointer
2407 ;          sspstrong attribute
2408 ; Requires protector.
2409 define void @test20c() nounwind uwtable sspstrong {
2410 entry:
2411 ; LINUX-I386: test20c:
2412 ; LINUX-I386: mov{{l|q}} %gs:
2413 ; LINUX-I386: calll __stack_chk_fail
2414
2415 ; LINUX-X64: test20c:
2416 ; LINUX-X64: mov{{l|q}} %fs:
2417 ; LINUX-X64: callq __stack_chk_fail
2418
2419 ; LINUX-KERNEL-X64: test20c:
2420 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2421 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2422
2423 ; DARWIN-X64: test20c:
2424 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2425 ; DARWIN-X64: callq ___stack_chk_fail
2426   %a = alloca i32*, align 8
2427   %b = alloca i32**, align 8
2428   %call = call i32* @getp()
2429   store i32* %call, i32** %a, align 8
2430   store i32** %a, i32*** %b, align 8
2431   %0 = load i32*** %b, align 8
2432   call void @funcall2(i32** %0)
2433   ret void
2434 }
2435
2436 ; test20d: Addr-of a pointer
2437 ;          sspreq attribute
2438 ; Requires protector.
2439 define void @test20d() nounwind uwtable sspreq {
2440 entry:
2441 ; LINUX-I386: test20d:
2442 ; LINUX-I386: mov{{l|q}} %gs:
2443 ; LINUX-I386: calll __stack_chk_fail
2444
2445 ; LINUX-X64: test20d:
2446 ; LINUX-X64: mov{{l|q}} %fs:
2447 ; LINUX-X64: callq __stack_chk_fail
2448
2449 ; LINUX-KERNEL-X64: test20d:
2450 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2451 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2452
2453 ; DARWIN-X64: test20d:
2454 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2455 ; DARWIN-X64: callq ___stack_chk_fail
2456   %a = alloca i32*, align 8
2457   %b = alloca i32**, align 8
2458   %call = call i32* @getp()
2459   store i32* %call, i32** %a, align 8
2460   store i32** %a, i32*** %b, align 8
2461   %0 = load i32*** %b, align 8
2462   call void @funcall2(i32** %0)
2463   ret void
2464 }
2465
2466 ; test21a: Addr-of a casted pointer
2467 ;          no ssp attribute
2468 ; Requires no protector.
2469 define void @test21a() nounwind uwtable {
2470 entry:
2471 ; LINUX-I386: test21a:
2472 ; LINUX-I386-NOT: calll __stack_chk_fail
2473 ; LINUX-I386: .cfi_endproc
2474
2475 ; LINUX-X64: test21a:
2476 ; LINUX-X64-NOT: callq __stack_chk_fail
2477 ; LINUX-X64: .cfi_endproc
2478
2479 ; LINUX-KERNEL-X64: test21a:
2480 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2481 ; LINUX-KERNEL-X64: .cfi_endproc
2482
2483 ; DARWIN-X64: test21a:
2484 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2485 ; DARWIN-X64: .cfi_endproc
2486   %a = alloca i32*, align 8
2487   %b = alloca float**, align 8
2488   %call = call i32* @getp()
2489   store i32* %call, i32** %a, align 8
2490   %0 = bitcast i32** %a to float**
2491   store float** %0, float*** %b, align 8
2492   %1 = load float*** %b, align 8
2493   call void @funfloat2(float** %1)
2494   ret void
2495 }
2496
2497 ; test21b: Addr-of a casted pointer
2498 ;          ssp attribute
2499 ; Requires no protector.
2500 define void @test21b() nounwind uwtable ssp {
2501 entry:
2502 ; LINUX-I386: test21b:
2503 ; LINUX-I386-NOT: calll __stack_chk_fail
2504 ; LINUX-I386: .cfi_endproc
2505
2506 ; LINUX-X64: test21b:
2507 ; LINUX-X64-NOT: callq __stack_chk_fail
2508 ; LINUX-X64: .cfi_endproc
2509
2510 ; LINUX-KERNEL-X64: test21b:
2511 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2512 ; LINUX-KERNEL-X64: .cfi_endproc
2513
2514 ; DARWIN-X64: test21b:
2515 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2516 ; DARWIN-X64: .cfi_endproc
2517   %a = alloca i32*, align 8
2518   %b = alloca float**, align 8
2519   %call = call i32* @getp()
2520   store i32* %call, i32** %a, align 8
2521   %0 = bitcast i32** %a to float**
2522   store float** %0, float*** %b, align 8
2523   %1 = load float*** %b, align 8
2524   call void @funfloat2(float** %1)
2525   ret void
2526 }
2527
2528 ; test21c: Addr-of a casted pointer
2529 ;          sspstrong attribute
2530 ; Requires protector.
2531 define void @test21c() nounwind uwtable sspstrong {
2532 entry:
2533 ; LINUX-I386: test21c:
2534 ; LINUX-I386: mov{{l|q}} %gs:
2535 ; LINUX-I386: calll __stack_chk_fail
2536
2537 ; LINUX-X64: test21c:
2538 ; LINUX-X64: mov{{l|q}} %fs:
2539 ; LINUX-X64: callq __stack_chk_fail
2540
2541 ; LINUX-KERNEL-X64: test21c:
2542 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2543 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2544
2545 ; DARWIN-X64: test21c:
2546 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2547 ; DARWIN-X64: callq ___stack_chk_fail
2548   %a = alloca i32*, align 8
2549   %b = alloca float**, align 8
2550   %call = call i32* @getp()
2551   store i32* %call, i32** %a, align 8
2552   %0 = bitcast i32** %a to float**
2553   store float** %0, float*** %b, align 8
2554   %1 = load float*** %b, align 8
2555   call void @funfloat2(float** %1)
2556   ret void
2557 }
2558
2559 ; test21d: Addr-of a casted pointer
2560 ;          sspreq attribute
2561 ; Requires protector.
2562 define void @test21d() nounwind uwtable sspreq {
2563 entry:
2564 ; LINUX-I386: test21d:
2565 ; LINUX-I386: mov{{l|q}} %gs:
2566 ; LINUX-I386: calll __stack_chk_fail
2567
2568 ; LINUX-X64: test21d:
2569 ; LINUX-X64: mov{{l|q}} %fs:
2570 ; LINUX-X64: callq __stack_chk_fail
2571
2572 ; LINUX-KERNEL-X64: test21d:
2573 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2574 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2575
2576 ; DARWIN-X64: test21d:
2577 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2578 ; DARWIN-X64: callq ___stack_chk_fail
2579   %a = alloca i32*, align 8
2580   %b = alloca float**, align 8
2581   %call = call i32* @getp()
2582   store i32* %call, i32** %a, align 8
2583   %0 = bitcast i32** %a to float**
2584   store float** %0, float*** %b, align 8
2585   %1 = load float*** %b, align 8
2586   call void @funfloat2(float** %1)
2587   ret void
2588 }
2589
2590 ; test22a: [2 x i8] in a class
2591 ;          no ssp attribute
2592 ; Requires no protector.
2593 define signext i8 @test22a() nounwind uwtable {
2594 entry:
2595 ; LINUX-I386: test22a:
2596 ; LINUX-I386-NOT: calll __stack_chk_fail
2597 ; LINUX-I386: .cfi_endproc
2598
2599 ; LINUX-X64: test22a:
2600 ; LINUX-X64-NOT: callq __stack_chk_fail
2601 ; LINUX-X64: .cfi_endproc
2602
2603 ; LINUX-KERNEL-X64: test22a:
2604 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2605 ; LINUX-KERNEL-X64: .cfi_endproc
2606
2607 ; DARWIN-X64: test22a:
2608 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2609 ; DARWIN-X64: .cfi_endproc
2610   %a = alloca %class.A, align 1
2611   %array = getelementptr inbounds %class.A* %a, i32 0, i32 0
2612   %arrayidx = getelementptr inbounds [2 x i8]* %array, i32 0, i64 0
2613   %0 = load i8* %arrayidx, align 1
2614   ret i8 %0
2615 }
2616
2617 ; test22b: [2 x i8] in a class
2618 ;          ssp attribute
2619 ; Requires no protector.
2620 define signext i8 @test22b() nounwind uwtable ssp {
2621 entry:
2622 ; LINUX-I386: test22b:
2623 ; LINUX-I386-NOT: calll __stack_chk_fail
2624 ; LINUX-I386: .cfi_endproc
2625
2626 ; LINUX-X64: test22b:
2627 ; LINUX-X64-NOT: callq __stack_chk_fail
2628 ; LINUX-X64: .cfi_endproc
2629
2630 ; LINUX-KERNEL-X64: test22b:
2631 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2632 ; LINUX-KERNEL-X64: .cfi_endproc
2633
2634 ; DARWIN-X64: test22b:
2635 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2636 ; DARWIN-X64: .cfi_endproc
2637   %a = alloca %class.A, align 1
2638   %array = getelementptr inbounds %class.A* %a, i32 0, i32 0
2639   %arrayidx = getelementptr inbounds [2 x i8]* %array, i32 0, i64 0
2640   %0 = load i8* %arrayidx, align 1
2641   ret i8 %0
2642 }
2643
2644 ; test22c: [2 x i8] in a class
2645 ;          sspstrong attribute
2646 ; Requires protector.
2647 define signext i8 @test22c() nounwind uwtable sspstrong {
2648 entry:
2649 ; LINUX-I386: test22c:
2650 ; LINUX-I386: mov{{l|q}} %gs:
2651 ; LINUX-I386: calll __stack_chk_fail
2652
2653 ; LINUX-X64: test22c:
2654 ; LINUX-X64: mov{{l|q}} %fs:
2655 ; LINUX-X64: callq __stack_chk_fail
2656
2657 ; LINUX-KERNEL-X64: test22c:
2658 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2659 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2660
2661 ; DARWIN-X64: test22c:
2662 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2663 ; DARWIN-X64: callq ___stack_chk_fail
2664   %a = alloca %class.A, align 1
2665   %array = getelementptr inbounds %class.A* %a, i32 0, i32 0
2666   %arrayidx = getelementptr inbounds [2 x i8]* %array, i32 0, i64 0
2667   %0 = load i8* %arrayidx, align 1
2668   ret i8 %0
2669 }
2670
2671 ; test22d: [2 x i8] in a class
2672 ;          sspreq attribute
2673 ; Requires protector.
2674 define signext i8 @test22d() nounwind uwtable sspreq {
2675 entry:
2676 ; LINUX-I386: test22d:
2677 ; LINUX-I386: mov{{l|q}} %gs:
2678 ; LINUX-I386: calll __stack_chk_fail
2679
2680 ; LINUX-X64: test22d:
2681 ; LINUX-X64: mov{{l|q}} %fs:
2682 ; LINUX-X64: callq __stack_chk_fail
2683
2684 ; LINUX-KERNEL-X64: test22d:
2685 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2686 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2687
2688 ; DARWIN-X64: test22d:
2689 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2690 ; DARWIN-X64: callq ___stack_chk_fail
2691   %a = alloca %class.A, align 1
2692   %array = getelementptr inbounds %class.A* %a, i32 0, i32 0
2693   %arrayidx = getelementptr inbounds [2 x i8]* %array, i32 0, i64 0
2694   %0 = load i8* %arrayidx, align 1
2695   ret i8 %0
2696 }
2697
2698 ; test23a: [2 x i8] nested in several layers of structs and unions
2699 ;          no ssp attribute
2700 ; Requires no protector.
2701 define signext i8 @test23a() nounwind uwtable {
2702 entry:
2703 ; LINUX-I386: test23a:
2704 ; LINUX-I386-NOT: calll __stack_chk_fail
2705 ; LINUX-I386: .cfi_endproc
2706
2707 ; LINUX-X64: test23a:
2708 ; LINUX-X64-NOT: callq __stack_chk_fail
2709 ; LINUX-X64: .cfi_endproc
2710
2711 ; LINUX-KERNEL-X64: test23a:
2712 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2713 ; LINUX-KERNEL-X64: .cfi_endproc
2714
2715 ; DARWIN-X64: test23a:
2716 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2717 ; DARWIN-X64: .cfi_endproc
2718   %x = alloca %struct.deep, align 1
2719   %b = getelementptr inbounds %struct.deep* %x, i32 0, i32 0
2720   %c = bitcast %union.anon* %b to %struct.anon*
2721   %d = getelementptr inbounds %struct.anon* %c, i32 0, i32 0
2722   %e = getelementptr inbounds %struct.anon.0* %d, i32 0, i32 0
2723   %array = bitcast %union.anon.1* %e to [2 x i8]*
2724   %arrayidx = getelementptr inbounds [2 x i8]* %array, i32 0, i64 0
2725   %0 = load i8* %arrayidx, align 1
2726   ret i8 %0
2727 }
2728
2729 ; test23b: [2 x i8] nested in several layers of structs and unions
2730 ;          ssp attribute
2731 ; Requires no protector.
2732 define signext i8 @test23b() nounwind uwtable ssp {
2733 entry:
2734 ; LINUX-I386: test23b:
2735 ; LINUX-I386-NOT: calll __stack_chk_fail
2736 ; LINUX-I386: .cfi_endproc
2737
2738 ; LINUX-X64: test23b:
2739 ; LINUX-X64-NOT: callq __stack_chk_fail
2740 ; LINUX-X64: .cfi_endproc
2741
2742 ; LINUX-KERNEL-X64: test23b:
2743 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2744 ; LINUX-KERNEL-X64: .cfi_endproc
2745
2746 ; DARWIN-X64: test23b:
2747 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2748 ; DARWIN-X64: .cfi_endproc
2749   %x = alloca %struct.deep, align 1
2750   %b = getelementptr inbounds %struct.deep* %x, i32 0, i32 0
2751   %c = bitcast %union.anon* %b to %struct.anon*
2752   %d = getelementptr inbounds %struct.anon* %c, i32 0, i32 0
2753   %e = getelementptr inbounds %struct.anon.0* %d, i32 0, i32 0
2754   %array = bitcast %union.anon.1* %e to [2 x i8]*
2755   %arrayidx = getelementptr inbounds [2 x i8]* %array, i32 0, i64 0
2756   %0 = load i8* %arrayidx, align 1
2757   ret i8 %0
2758 }
2759
2760 ; test23c: [2 x i8] nested in several layers of structs and unions
2761 ;          sspstrong attribute
2762 ; Requires protector.
2763 define signext i8 @test23c() nounwind uwtable sspstrong {
2764 entry:
2765 ; LINUX-I386: test23c:
2766 ; LINUX-I386: mov{{l|q}} %gs:
2767 ; LINUX-I386: calll __stack_chk_fail
2768
2769 ; LINUX-X64: test23c:
2770 ; LINUX-X64: mov{{l|q}} %fs:
2771 ; LINUX-X64: callq __stack_chk_fail
2772
2773 ; LINUX-KERNEL-X64: test23c:
2774 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2775 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2776
2777 ; DARWIN-X64: test23c:
2778 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2779 ; DARWIN-X64: callq ___stack_chk_fail
2780   %x = alloca %struct.deep, align 1
2781   %b = getelementptr inbounds %struct.deep* %x, i32 0, i32 0
2782   %c = bitcast %union.anon* %b to %struct.anon*
2783   %d = getelementptr inbounds %struct.anon* %c, i32 0, i32 0
2784   %e = getelementptr inbounds %struct.anon.0* %d, i32 0, i32 0
2785   %array = bitcast %union.anon.1* %e to [2 x i8]*
2786   %arrayidx = getelementptr inbounds [2 x i8]* %array, i32 0, i64 0
2787   %0 = load i8* %arrayidx, align 1
2788   ret i8 %0
2789 }
2790
2791 ; test23d: [2 x i8] nested in several layers of structs and unions
2792 ;          sspreq attribute
2793 ; Requires protector.
2794 define signext i8 @test23d() nounwind uwtable sspreq {
2795 entry:
2796 ; LINUX-I386: test23d:
2797 ; LINUX-I386: mov{{l|q}} %gs:
2798 ; LINUX-I386: calll __stack_chk_fail
2799
2800 ; LINUX-X64: test23d:
2801 ; LINUX-X64: mov{{l|q}} %fs:
2802 ; LINUX-X64: callq __stack_chk_fail
2803
2804 ; LINUX-KERNEL-X64: test23d:
2805 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2806 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2807
2808 ; DARWIN-X64: test23d:
2809 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2810 ; DARWIN-X64: callq ___stack_chk_fail
2811   %x = alloca %struct.deep, align 1
2812   %b = getelementptr inbounds %struct.deep* %x, i32 0, i32 0
2813   %c = bitcast %union.anon* %b to %struct.anon*
2814   %d = getelementptr inbounds %struct.anon* %c, i32 0, i32 0
2815   %e = getelementptr inbounds %struct.anon.0* %d, i32 0, i32 0
2816   %array = bitcast %union.anon.1* %e to [2 x i8]*
2817   %arrayidx = getelementptr inbounds [2 x i8]* %array, i32 0, i64 0
2818   %0 = load i8* %arrayidx, align 1
2819   ret i8 %0
2820 }
2821
2822 ; test24a: Variable sized alloca
2823 ;          no ssp attribute
2824 ; Requires no protector.
2825 define void @test24a(i32 %n) nounwind uwtable {
2826 entry:
2827 ; LINUX-I386: test24a:
2828 ; LINUX-I386-NOT: calll __stack_chk_fail
2829 ; LINUX-I386: .cfi_endproc
2830
2831 ; LINUX-X64: test24a:
2832 ; LINUX-X64-NOT: callq __stack_chk_fail
2833 ; LINUX-X64: .cfi_endproc
2834
2835 ; LINUX-KERNEL-X64: test24a:
2836 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2837 ; LINUX-KERNEL-X64: .cfi_endproc
2838
2839 ; DARWIN-X64: test24a:
2840 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2841 ; DARWIN-X64: .cfi_endproc
2842   %n.addr = alloca i32, align 4
2843   %a = alloca i32*, align 8
2844   store i32 %n, i32* %n.addr, align 4
2845   %0 = load i32* %n.addr, align 4
2846   %conv = sext i32 %0 to i64
2847   %1 = alloca i8, i64 %conv
2848   %2 = bitcast i8* %1 to i32*
2849   store i32* %2, i32** %a, align 8
2850   ret void
2851 }
2852
2853 ; test24b: Variable sized alloca
2854 ;          ssp attribute
2855 ; Requires protector.
2856 define void @test24b(i32 %n) nounwind uwtable ssp {
2857 entry:
2858 ; LINUX-I386: test24b:
2859 ; LINUX-I386: mov{{l|q}} %gs:
2860 ; LINUX-I386: calll __stack_chk_fail
2861
2862 ; LINUX-X64: test24b:
2863 ; LINUX-X64: mov{{l|q}} %fs:
2864 ; LINUX-X64: callq __stack_chk_fail
2865
2866 ; LINUX-KERNEL-X64: test24b:
2867 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2868 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2869
2870 ; DARWIN-X64: test24b:
2871 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2872 ; DARWIN-X64: callq ___stack_chk_fail
2873   %n.addr = alloca i32, align 4
2874   %a = alloca i32*, align 8
2875   store i32 %n, i32* %n.addr, align 4
2876   %0 = load i32* %n.addr, align 4
2877   %conv = sext i32 %0 to i64
2878   %1 = alloca i8, i64 %conv
2879   %2 = bitcast i8* %1 to i32*
2880   store i32* %2, i32** %a, align 8
2881   ret void
2882 }
2883
2884 ; test24c: Variable sized alloca
2885 ;          sspstrong attribute
2886 ; Requires protector.
2887 define void @test24c(i32 %n) nounwind uwtable sspstrong {
2888 entry:
2889 ; LINUX-I386: test24c:
2890 ; LINUX-I386: mov{{l|q}} %gs:
2891 ; LINUX-I386: calll __stack_chk_fail
2892
2893 ; LINUX-X64: test24c:
2894 ; LINUX-X64: mov{{l|q}} %fs:
2895 ; LINUX-X64: callq __stack_chk_fail
2896
2897 ; LINUX-KERNEL-X64: test24c:
2898 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2899 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2900
2901 ; DARWIN-X64: test24c:
2902 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2903 ; DARWIN-X64: callq ___stack_chk_fail
2904   %n.addr = alloca i32, align 4
2905   %a = alloca i32*, align 8
2906   store i32 %n, i32* %n.addr, align 4
2907   %0 = load i32* %n.addr, align 4
2908   %conv = sext i32 %0 to i64
2909   %1 = alloca i8, i64 %conv
2910   %2 = bitcast i8* %1 to i32*
2911   store i32* %2, i32** %a, align 8
2912   ret void
2913 }
2914
2915 ; test24d: Variable sized alloca
2916 ;          sspreq attribute
2917 ; Requires protector.
2918 define void @test24d(i32 %n) nounwind uwtable sspreq  {
2919 entry:
2920 ; LINUX-I386: test24d:
2921 ; LINUX-I386: mov{{l|q}} %gs:
2922 ; LINUX-I386: calll __stack_chk_fail
2923
2924 ; LINUX-X64: test24d:
2925 ; LINUX-X64: mov{{l|q}} %fs:
2926 ; LINUX-X64: callq __stack_chk_fail
2927
2928 ; LINUX-KERNEL-X64: test24d:
2929 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
2930 ; LINUX-KERNEL-X64: callq __stack_chk_fail
2931
2932 ; DARWIN-X64: test24d:
2933 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2934 ; DARWIN-X64: callq ___stack_chk_fail
2935   %n.addr = alloca i32, align 4
2936   %a = alloca i32*, align 8
2937   store i32 %n, i32* %n.addr, align 4
2938   %0 = load i32* %n.addr, align 4
2939   %conv = sext i32 %0 to i64
2940   %1 = alloca i8, i64 %conv
2941   %2 = bitcast i8* %1 to i32*
2942   store i32* %2, i32** %a, align 8
2943   ret void
2944 }
2945
2946 ; test25a: array of [4 x i32]
2947 ;          no ssp attribute
2948 ; Requires no protector.
2949 define i32 @test25a() nounwind uwtable {
2950 entry:
2951 ; LINUX-I386: test25a:
2952 ; LINUX-I386-NOT: calll __stack_chk_fail
2953 ; LINUX-I386: .cfi_endproc
2954
2955 ; LINUX-X64: test25a:
2956 ; LINUX-X64-NOT: callq __stack_chk_fail
2957 ; LINUX-X64: .cfi_endproc
2958
2959 ; LINUX-KERNEL-X64: test25a:
2960 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2961 ; LINUX-KERNEL-X64: .cfi_endproc
2962
2963 ; DARWIN-X64: test25a:
2964 ; DARWIN-X64-NOT: callq ___stack_chk_fail
2965 ; DARWIN-X64: .cfi_endproc
2966   %a = alloca [4 x i32], align 16
2967   %arrayidx = getelementptr inbounds [4 x i32]* %a, i32 0, i64 0
2968   %0 = load i32* %arrayidx, align 4
2969   ret i32 %0
2970 }
2971
2972 ; test25b: array of [4 x i32]
2973 ;          ssp attribute
2974 ; Requires no protector, except for Darwin which _does_ require a protector.
2975 define i32 @test25b() nounwind uwtable ssp {
2976 entry:
2977 ; LINUX-I386: test25b:
2978 ; LINUX-I386-NOT: calll __stack_chk_fail
2979 ; LINUX-I386: .cfi_endproc
2980
2981 ; LINUX-X64: test25b:
2982 ; LINUX-X64-NOT: callq __stack_chk_fail
2983 ; LINUX-X64: .cfi_endproc
2984
2985 ; LINUX-KERNEL-X64: test25b:
2986 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
2987 ; LINUX-KERNEL-X64: .cfi_endproc
2988
2989 ; DARWIN-X64: test25b:
2990 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
2991 ; DARWIN-X64: callq ___stack_chk_fail
2992   %a = alloca [4 x i32], align 16
2993   %arrayidx = getelementptr inbounds [4 x i32]* %a, i32 0, i64 0
2994   %0 = load i32* %arrayidx, align 4
2995   ret i32 %0
2996 }
2997
2998 ; test25c: array of [4 x i32]
2999 ;          sspstrong attribute
3000 ; Requires protector.
3001 define i32 @test25c() nounwind uwtable sspstrong {
3002 entry:
3003 ; LINUX-I386: test25c:
3004 ; LINUX-I386: mov{{l|q}} %gs:
3005 ; LINUX-I386: calll __stack_chk_fail
3006
3007 ; LINUX-X64: test25c:
3008 ; LINUX-X64: mov{{l|q}} %fs:
3009 ; LINUX-X64: callq __stack_chk_fail
3010
3011 ; LINUX-KERNEL-X64: test25c:
3012 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
3013 ; LINUX-KERNEL-X64: callq __stack_chk_fail
3014
3015 ; DARWIN-X64: test25c:
3016 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
3017 ; DARWIN-X64: callq ___stack_chk_fail
3018   %a = alloca [4 x i32], align 16
3019   %arrayidx = getelementptr inbounds [4 x i32]* %a, i32 0, i64 0
3020   %0 = load i32* %arrayidx, align 4
3021   ret i32 %0
3022 }
3023
3024 ; test25d: array of [4 x i32]
3025 ;          sspreq attribute
3026 ; Requires protector.
3027 define i32 @test25d() nounwind uwtable sspreq {
3028 entry:
3029 ; LINUX-I386: test25d:
3030 ; LINUX-I386: mov{{l|q}} %gs:
3031 ; LINUX-I386: calll __stack_chk_fail
3032
3033 ; LINUX-X64: test25d:
3034 ; LINUX-X64: mov{{l|q}} %fs:
3035 ; LINUX-X64: callq __stack_chk_fail
3036
3037 ; LINUX-KERNEL-X64: test25d:
3038 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
3039 ; LINUX-KERNEL-X64: callq __stack_chk_fail
3040
3041 ; DARWIN-X64: test25d:
3042 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
3043 ; DARWIN-X64: callq ___stack_chk_fail
3044   %a = alloca [4 x i32], align 16
3045   %arrayidx = getelementptr inbounds [4 x i32]* %a, i32 0, i64 0
3046   %0 = load i32* %arrayidx, align 4
3047   ret i32 %0
3048 }
3049
3050 ; test26: Nested structure, no arrays, no address-of expressions.
3051 ;         Verify that the resulting gep-of-gep does not incorrectly trigger
3052 ;         a stack protector.
3053 ;         ssptrong attribute
3054 ; Requires no protector.
3055 define void @test26() nounwind uwtable sspstrong {
3056 entry:
3057 ; LINUX-I386: test26:
3058 ; LINUX-I386-NOT: calll __stack_chk_fail
3059 ; LINUX-I386: .cfi_endproc
3060
3061 ; LINUX-X64: test26:
3062 ; LINUX-X64-NOT: callq __stack_chk_fail
3063 ; LINUX-X64: .cfi_endproc
3064
3065 ; LINUX-KERNEL-X64: test26:
3066 ; LINUX-KERNEL-X64-NOT: callq __stack_chk_fail
3067 ; LINUX-KERNEL-X64: .cfi_endproc
3068
3069 ; DARWIN-X64: test26:
3070 ; DARWIN-X64-NOT: callq ___stack_chk_fail
3071 ; DARWIN-X64: .cfi_endproc
3072   %c = alloca %struct.nest, align 4
3073   %b = getelementptr inbounds %struct.nest* %c, i32 0, i32 1
3074   %_a = getelementptr inbounds %struct.pair* %b, i32 0, i32 0
3075   %0 = load i32* %_a, align 4
3076   %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i32 %0)
3077   ret void
3078 }
3079
3080 ; test27: Address-of a structure taken in a function with a loop where
3081 ;         the alloca is an incoming value to a PHI node and a use of that PHI 
3082 ;         node is also an incoming value.
3083 ;         Verify that the address-of analysis does not get stuck in infinite
3084 ;         recursion when chasing the alloca through the PHI nodes.
3085 ; Requires protector.
3086 define i32 @test27(i32 %arg) nounwind uwtable sspstrong {
3087 bb:
3088 ; LINUX-I386: test27:
3089 ; LINUX-I386: mov{{l|q}} %gs:
3090 ; LINUX-I386: calll __stack_chk_fail
3091
3092 ; LINUX-X64: test27:
3093 ; LINUX-X64: mov{{l|q}} %fs:
3094 ; LINUX-X64: callq __stack_chk_fail
3095
3096 ; LINUX-KERNEL-X64: test27:
3097 ; LINUX-KERNEL-X64: mov{{l|q}} %gs:
3098 ; LINUX-KERNEL-X64: callq __stack_chk_fail
3099
3100 ; DARWIN-X64: test27:
3101 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
3102 ; DARWIN-X64: callq ___stack_chk_fail
3103   %tmp = alloca %struct.small*, align 8
3104   %tmp1 = call i32 (...)* @dummy(%struct.small** %tmp) nounwind
3105   %tmp2 = load %struct.small** %tmp, align 8
3106   %tmp3 = ptrtoint %struct.small* %tmp2 to i64
3107   %tmp4 = trunc i64 %tmp3 to i32
3108   %tmp5 = icmp sgt i32 %tmp4, 0
3109   br i1 %tmp5, label %bb6, label %bb21
3110
3111 bb6:                                              ; preds = %bb17, %bb
3112   %tmp7 = phi %struct.small* [ %tmp19, %bb17 ], [ %tmp2, %bb ]
3113   %tmp8 = phi i64 [ %tmp20, %bb17 ], [ 1, %bb ]
3114   %tmp9 = phi i32 [ %tmp14, %bb17 ], [ %tmp1, %bb ]
3115   %tmp10 = getelementptr inbounds %struct.small* %tmp7, i64 0, i32 0
3116   %tmp11 = load i8* %tmp10, align 1
3117   %tmp12 = icmp eq i8 %tmp11, 1
3118   %tmp13 = add nsw i32 %tmp9, 8
3119   %tmp14 = select i1 %tmp12, i32 %tmp13, i32 %tmp9
3120   %tmp15 = trunc i64 %tmp8 to i32
3121   %tmp16 = icmp eq i32 %tmp15, %tmp4
3122   br i1 %tmp16, label %bb21, label %bb17
3123
3124 bb17:                                             ; preds = %bb6
3125   %tmp18 = getelementptr inbounds %struct.small** %tmp, i64 %tmp8
3126   %tmp19 = load %struct.small** %tmp18, align 8
3127   %tmp20 = add i64 %tmp8, 1
3128   br label %bb6
3129
3130 bb21:                                             ; preds = %bb6, %bb
3131   %tmp22 = phi i32 [ %tmp1, %bb ], [ %tmp14, %bb6 ]
3132   %tmp23 = call i32 (...)* @dummy(i32 %tmp22) nounwind
3133   ret i32 undef
3134 }
3135
3136 declare double @testi_aux()
3137 declare i8* @strcpy(i8*, i8*)
3138 declare i32 @printf(i8*, ...)
3139 declare void @funcall(i32*)
3140 declare void @funcall2(i32**)
3141 declare void @funfloat(float*)
3142 declare void @funfloat2(float**)
3143 declare void @_Z3exceptPi(i32*)
3144 declare i32 @__gxx_personality_v0(...)
3145 declare i32* @getp()
3146 declare i32 @dummy(...)