1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-23 04:52:54 +02:00
llvm-mirror/test/Transforms/SafeStack/X86/ssp.ll
Evgeniy Stepanov b10de1bbaa [safestack] Add canary to unsafe stack frames
Add StackProtector to SafeStack. This adds limited protection against
data corruption in the caller frame. Current implementation treats
all stack protector levels as -fstack-protector-all.

llvm-svn: 266004
2016-04-11 22:27:48 +00:00

31 lines
1010 B
LLVM

; RUN: opt -safe-stack -S -mtriple=x86_64-unknown < %s -o - | FileCheck %s
define void @foo() safestack sspreq {
entry:
; CHECK: %[[USP:.*]] = load i8*, i8** @__safestack_unsafe_stack_ptr
; CHECK: %[[USST:.*]] = getelementptr i8, i8* %[[USP]], i32 -16
; CHECK: store i8* %[[USST]], i8** @__safestack_unsafe_stack_ptr
; CHECK: %[[A:.*]] = getelementptr i8, i8* %[[USP]], i32 -8
; CHECK: %[[StackGuardSlot:.*]] = bitcast i8* %[[A]] to i8**
; CHECK: %[[StackGuard:.*]] = load i8*, i8** @__stack_chk_guard
; CHECK: store i8* %[[StackGuard]], i8** %[[StackGuardSlot]]
%a = alloca i8, align 1
; CHECK: call void @Capture
call void @Capture(i8* %a)
; CHECK: %[[B:.*]] = load i8*, i8** %[[StackGuardSlot]]
; CHECK: %[[COND:.*]] = icmp ne i8* %[[StackGuard]], %[[B]]
; CHECK: br i1 %[[COND]], {{.*}} !prof
; CHECK: call void @__stack_chk_fail()
; CHECK-NEXT: unreachable
; CHECK: store i8* %[[USP]], i8** @__safestack_unsafe_stack_ptr
; CHECK-NEXT: ret void
ret void
}
declare void @Capture(i8*)