1 ; RUN: opt -safe-stack -S -mtriple=x86_64-unknown < %s -o - | FileCheck %s
3 define void @foo() safestack sspreq {
5 ; CHECK: %[[USP:.*]] = load i8*, i8** @__safestack_unsafe_stack_ptr
6 ; CHECK: %[[USST:.*]] = getelementptr i8, i8* %[[USP]], i32 -16
7 ; CHECK: store i8* %[[USST]], i8** @__safestack_unsafe_stack_ptr
9 ; CHECK: %[[A:.*]] = getelementptr i8, i8* %[[USP]], i32 -8
10 ; CHECK: %[[StackGuardSlot:.*]] = bitcast i8* %[[A]] to i8**
11 ; CHECK: %[[StackGuard:.*]] = load i8*, i8** @__stack_chk_guard
12 ; CHECK: store i8* %[[StackGuard]], i8** %[[StackGuardSlot]]
13 %a = alloca i8, align 1
15 ; CHECK: call void @Capture
16 call void @Capture(i8* %a)
18 ; CHECK: %[[B:.*]] = load i8*, i8** %[[StackGuardSlot]]
19 ; CHECK: %[[COND:.*]] = icmp ne i8* %[[StackGuard]], %[[B]]
20 ; CHECK: br i1 %[[COND]], {{.*}} !prof
22 ; CHECK: call void @__stack_chk_fail()
23 ; CHECK-NEXT: unreachable
25 ; CHECK: store i8* %[[USP]], i8** @__safestack_unsafe_stack_ptr
26 ; CHECK-NEXT: ret void
30 declare void @Capture(i8*)