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
10 define void @foo(ptr %a) nounwind uwtable safestack {
12 ; CHECK: %[[USP:.*]] = load ptr, ptr @__safestack_unsafe_stack_ptr
14 ; CHECK: %[[USST:.*]] = getelementptr i8, ptr %[[USP]], i32 -16
16 ; CHECK: store ptr %[[USST]], ptr @__safestack_unsafe_stack_ptr
18 %a.addr = alloca ptr, align 8
19 %buf = alloca [16 x i8], align 16
21 ; CHECK: %[[AADDR:.*]] = alloca ptr, align 8
22 ; CHECK: store ptr {{.*}}, ptr %[[AADDR]], align 8
23 store ptr %a, ptr %a.addr, align 8
25 ; CHECK: %[[A2:.*]] = load ptr, ptr %[[AADDR]], align 8
26 ; CHECK: %[[BUFPTR:.*]] = getelementptr i8, ptr %[[USP]], i32 -16
27 %a2 = load ptr, ptr %a.addr, align 8
29 ; CHECK: call ptr @strcpy(ptr %[[BUFPTR]], ptr %[[A2]])
30 %call = call ptr @strcpy(ptr %buf, ptr %a2)
32 ; CHECK: store ptr %[[USP]], ptr @__safestack_unsafe_stack_ptr
36 declare ptr @strcpy(ptr, ptr)