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 %struct.foo = type { [16 x i8] }
8 @.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
10 ; struct { [16 x i8] }
12 define void @foo(ptr %a) nounwind uwtable safestack {
14 ; CHECK: %[[USP:.*]] = load ptr, ptr @__safestack_unsafe_stack_ptr
16 ; CHECK: %[[USST:.*]] = getelementptr i8, ptr %[[USP]], i32 -16
18 ; CHECK: store ptr %[[USST]], ptr @__safestack_unsafe_stack_ptr
20 %a.addr = alloca ptr, align 8
21 %buf = alloca %struct.foo, align 1
23 ; CHECK: %[[AADDR:.*]] = alloca ptr, align 8
24 ; CHECK: store ptr {{.*}}, ptr %[[AADDR]], align 8
25 store ptr %a, ptr %a.addr, align 8
27 ; CHECK: %[[A:.*]] = load ptr, ptr %[[AADDR]], align 8
28 ; CHECK: %[[BUFPTR:.*]] = getelementptr i8, ptr %[[USP]], i32 -16
29 %a2 = load ptr, ptr %a.addr, align 8
31 ; CHECK: call ptr @strcpy(ptr %[[BUFPTR]], ptr %[[A]])
32 %call = call ptr @strcpy(ptr %buf, ptr %a2)
34 ; CHECK: store ptr %[[USP]], ptr @__safestack_unsafe_stack_ptr
38 declare ptr @strcpy(ptr, ptr)