1 ; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
2 ; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
4 @.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
6 define void @bad_store() nounwind uwtable safestack {
8 ; CHECK-LABEL: @bad_store(
9 ; CHECK: __safestack_unsafe_stack_ptr
11 %a = alloca i32, align 4
12 %0 = ptrtoint i32* %a to i64
13 %1 = inttoptr i64 %0 to i64*
14 store i64 zeroinitializer, i64* %1
18 define void @good_store() nounwind uwtable safestack {
20 ; CHECK-LABEL: @good_store(
21 ; CHECK-NOT: __safestack_unsafe_stack_ptr
23 %a = alloca i32, align 4
24 %0 = bitcast i32* %a to i8*
25 store i8 zeroinitializer, i8* %0
29 define void @overflow_gep_store() nounwind uwtable safestack {
31 ; CHECK-LABEL: @overflow_gep_store(
32 ; CHECK: __safestack_unsafe_stack_ptr
34 %a = alloca i32, align 4
35 %0 = bitcast i32* %a to i8*
36 %1 = getelementptr i8, i8* %0, i32 4
37 store i8 zeroinitializer, i8* %1
41 define void @underflow_gep_store() nounwind uwtable safestack {
43 ; CHECK-LABEL: @underflow_gep_store(
44 ; CHECK: __safestack_unsafe_stack_ptr
46 %a = alloca i32, align 4
47 %0 = bitcast i32* %a to i8*
48 %1 = getelementptr i8, i8* %0, i32 -1
49 store i8 zeroinitializer, i8* %1
53 define void @good_gep_store() nounwind uwtable safestack {
55 ; CHECK-LABEL: @good_gep_store(
56 ; CHECK-NOT: __safestack_unsafe_stack_ptr
58 %a = alloca i32, align 4
59 %0 = bitcast i32* %a to i8*
60 %1 = getelementptr i8, i8* %0, i32 3
61 store i8 zeroinitializer, i8* %1