52 lines · plain
1; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s2; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s3; RUN: opt -passes=safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s4; RUN: opt -passes=safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s5 6%struct.small = type { i8 }7 8@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 19 10; Address-of a structure taken in a function with a loop where11; the alloca is an incoming value to a PHI node and a use of that PHI12; node is also an incoming value.13; Verify that the address-of analysis does not get stuck in infinite14; recursion when chasing the alloca through the PHI nodes.15; Requires protector.16define i32 @foo(i32 %arg) nounwind uwtable safestack {17bb:18 ; CHECK: __safestack_unsafe_stack_ptr19 %tmp = alloca ptr, align 820 %tmp1 = call i32 (...) @dummy(ptr %tmp) nounwind21 %tmp2 = load ptr, ptr %tmp, align 822 %tmp3 = ptrtoint ptr %tmp2 to i6423 %tmp4 = trunc i64 %tmp3 to i3224 %tmp5 = icmp sgt i32 %tmp4, 025 br i1 %tmp5, label %bb6, label %bb2126 27bb6: ; preds = %bb17, %bb28 %tmp7 = phi ptr [ %tmp19, %bb17 ], [ %tmp2, %bb ]29 %tmp8 = phi i64 [ %tmp20, %bb17 ], [ 1, %bb ]30 %tmp9 = phi i32 [ %tmp14, %bb17 ], [ %tmp1, %bb ]31 %tmp11 = load i8, ptr %tmp7, align 132 %tmp12 = icmp eq i8 %tmp11, 133 %tmp13 = add nsw i32 %tmp9, 834 %tmp14 = select i1 %tmp12, i32 %tmp13, i32 %tmp935 %tmp15 = trunc i64 %tmp8 to i3236 %tmp16 = icmp eq i32 %tmp15, %tmp437 br i1 %tmp16, label %bb21, label %bb1738 39bb17: ; preds = %bb640 %tmp18 = getelementptr inbounds ptr, ptr %tmp, i64 %tmp841 %tmp19 = load ptr, ptr %tmp18, align 842 %tmp20 = add i64 %tmp8, 143 br label %bb644 45bb21: ; preds = %bb6, %bb46 %tmp22 = phi i32 [ %tmp1, %bb ], [ %tmp14, %bb6 ]47 %tmp23 = call i32 (...) @dummy(i32 %tmp22) nounwind48 ret i32 undef49}50 51declare i32 @dummy(...)52