1 ; RUN: llc < %s | FileCheck %s
2 target triple = "x86_64-apple-macosx10.4.0"
4 ; __stack_chk_guard must be loaded for twice, once for setting up the canary,
5 ; another time for performing the check. It is because if we reuse the same
6 ; stack guard value, it may get spilled to the stack, then the for loop may
12 ; for (int i = 0; i < n; i++) {
18 ; CHECK: movq ___stack_chk_guard
19 ; CHECK: movq ___stack_chk_guard
20 define zeroext i1 @_Z3Fooi(i32 %n) sspstrong {
22 %n.addr = alloca i32, align 4
23 %a = alloca [10 x i32], align 16
24 %i = alloca i32, align 4
25 store i32 %n, i32* %n.addr, align 4
26 store i32 0, i32* %i, align 4
29 for.cond: ; preds = %for.inc, %entry
30 %tmp = load i32, i32* %i, align 4
31 %tmp1 = load i32, i32* %n.addr, align 4
32 %cmp = icmp slt i32 %tmp, %tmp1
33 br i1 %cmp, label %for.body, label %for.end
35 for.body: ; preds = %for.cond
36 %tmp2 = load i32, i32* %i, align 4
37 %idxprom = sext i32 %tmp2 to i64
38 %arrayidx = getelementptr inbounds [10 x i32], [10 x i32]* %a, i64 0, i64 %idxprom
39 store i32 0, i32* %arrayidx, align 4
42 for.inc: ; preds = %for.body
43 %tmp3 = load i32, i32* %i, align 4
44 %inc = add nsw i32 %tmp3, 1
45 store i32 %inc, i32* %i, align 4
48 for.end: ; preds = %for.cond
49 %arraydecay = getelementptr inbounds [10 x i32], [10 x i32]* %a, i32 0, i32 0
50 %call = call zeroext i1 @_Z3BarPi(i32* %arraydecay)
54 declare zeroext i1 @_Z3BarPi(i32*)