reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
; 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*)