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
3 ; RUN: opt -passes=safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
4 ; RUN: opt -passes=safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
6 @.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
8 define void @bad_store() nounwind uwtable safestack {
10 ; CHECK-LABEL: @bad_store(
11 ; CHECK: __safestack_unsafe_stack_ptr
13 %a = alloca i32, align 4
14 %0 = ptrtoint ptr %a to i64
15 %1 = inttoptr i64 %0 to ptr
16 store i64 zeroinitializer, ptr %1
20 define void @good_store() nounwind uwtable safestack {
22 ; CHECK-LABEL: @good_store(
23 ; CHECK-NOT: __safestack_unsafe_stack_ptr
25 %a = alloca i32, align 4
26 store i8 zeroinitializer, ptr %a
30 define void @overflow_gep_store() nounwind uwtable safestack {
32 ; CHECK-LABEL: @overflow_gep_store(
33 ; CHECK: __safestack_unsafe_stack_ptr
35 %a = alloca i32, align 4
36 %0 = getelementptr i8, ptr %a, i32 4
37 store i8 zeroinitializer, ptr %0
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 = getelementptr i8, ptr %a, i32 -1
48 store i8 zeroinitializer, ptr %0
52 define void @good_gep_store() nounwind uwtable safestack {
54 ; CHECK-LABEL: @good_gep_store(
55 ; CHECK-NOT: __safestack_unsafe_stack_ptr
57 %a = alloca i32, align 4
58 %0 = getelementptr i8, ptr %a, i32 3
59 store i8 zeroinitializer, ptr %0