brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 0f25b2b Raw
54 lines · plain
1; RUN: llc < %s | FileCheck %s2target triple = "x86_64-apple-macosx10.4.0"3 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 same6; stack guard value, it may get spilled to the stack, then the for loop may7; corrupt it.8;9; bool Bar(int*);10; bool Foo(int n) {11;   int a[10];12;   for (int i = 0; i < n; i++) {13;     a[i] = 0;14;   }15;   return Bar(a);16; }17;18; CHECK: movq ___stack_chk_guard19; CHECK: movq ___stack_chk_guard20define zeroext i1 @_Z3Fooi(i32 %n) sspstrong {21entry:22  %n.addr = alloca i32, align 423  %a = alloca [10 x i32], align 1624  %i = alloca i32, align 425  store i32 %n, ptr %n.addr, align 426  store i32 0, ptr %i, align 427  br label %for.cond28 29for.cond:                                         ; preds = %for.inc, %entry30  %tmp = load i32, ptr %i, align 431  %tmp1 = load i32, ptr %n.addr, align 432  %cmp = icmp slt i32 %tmp, %tmp133  br i1 %cmp, label %for.body, label %for.end34 35for.body:                                         ; preds = %for.cond36  %tmp2 = load i32, ptr %i, align 437  %idxprom = sext i32 %tmp2 to i6438  %arrayidx = getelementptr inbounds [10 x i32], ptr %a, i64 0, i64 %idxprom39  store i32 0, ptr %arrayidx, align 440  br label %for.inc41 42for.inc:                                          ; preds = %for.body43  %tmp3 = load i32, ptr %i, align 444  %inc = add nsw i32 %tmp3, 145  store i32 %inc, ptr %i, align 446  br label %for.cond47 48for.end:                                          ; preds = %for.cond49  %call = call zeroext i1 @_Z3BarPi(ptr %a)50  ret i1 %call51}52 53declare zeroext i1 @_Z3BarPi(ptr)54