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
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
; RUN: llc %s -mtriple=x86_64-unknown-unknown -pass-remarks=stack-protector -o /dev/null 2>&1 | FileCheck %s
; CHECK-NOT: nossp
; CHECK: function attribute_ssp
; CHECK-SAME: a function attribute or command-line switch
; CHECK-NOT: alloca_fixed_small_nossp
; CHECK: function alloca_fixed_small_ssp
; CHECK-SAME: a call to alloca or use of a variable length array
; CHECK: function alloca_fixed_large_ssp
; CHECK-SAME: a call to alloca or use of a variable length array
; CHECK: function alloca_variable_ssp
; CHECK-SAME: a call to alloca or use of a variable length array
; CHECK: function buffer_ssp
; CHECK-SAME: a stack allocated buffer or struct containing a buffer
; CHECK: function struct_ssp
; CHECK-SAME: a stack allocated buffer or struct containing a buffer
; CHECK: function address_ssp
; CHECK-SAME: the address of a local variable being taken
; CHECK: function multiple_ssp
; CHECK-SAME: a function attribute or command-line switch
; CHECK: function multiple_ssp
; CHECK-SAME: a stack allocated buffer or struct containing a buffer
; CHECK: function multiple_ssp
; CHECK-SAME: a stack allocated buffer or struct containing a buffer
; CHECK: function multiple_ssp
; CHECK-SAME: the address of a local variable being taken
; CHECK: function multiple_ssp
; CHECK-SAME: a call to alloca or use of a variable length array

; Check that no remark is emitted when the switch is not specified.
; RUN: llc %s -mtriple=x86_64-unknown-unknown -o /dev/null 2>&1 | FileCheck %s -check-prefix=NOREMARK -allow-empty
; NOREMARK-NOT: ssp

; RUN: llc %s -mtriple=x86_64-unknown-unknown -o /dev/null -pass-remarks-output=%t.yaml
; RUN: cat %t.yaml | FileCheck %s -check-prefix=YAML
; YAML:      --- !Passed
; YAML-NEXT: Pass:            stack-protector
; YAML-NEXT: Name:            StackProtectorRequested
; YAML-NEXT: Function:        attribute_ssp
; YAML-NEXT: Args:
; YAML-NEXT:   - String:          'Stack protection applied to function '
; YAML-NEXT:   - Function:        attribute_ssp
; YAML-NEXT:   - String:          ' due to a function attribute or command-line switch'
; YAML-NEXT: ...

define void @nossp() ssp {
  ret void
}

define void @attribute_ssp() sspreq {
  ret void
}

define void @alloca_fixed_small_nossp() ssp {
  %1 = alloca i8, i64 2, align 16
  ret void
}

define void @alloca_fixed_small_ssp() sspstrong {
  %1 = alloca i8, i64 2, align 16
  ret void
}

define void @alloca_fixed_large_ssp() ssp {
  %1 = alloca i8, i64 64, align 16
  ret void
}

define void @alloca_variable_ssp(i64 %x) ssp {
  %1 = alloca i8, i64 %x, align 16
  ret void
}

define void @buffer_ssp() sspstrong {
  %x = alloca [64 x i32], align 16
  ret void
}

%struct.X = type { [64 x i32] }
define void @struct_ssp() sspstrong {
  %x = alloca %struct.X, align 4
  ret void
}

define void @address_ssp() sspstrong {
entry:
  %x = alloca i32, align 4
  %y = alloca i32*, align 8
  store i32 32, i32* %x, align 4
  store i32* %x, i32** %y, align 8
  ret void
}

define void @multiple_ssp() sspreq {
entry:
  %x = alloca %struct.X, align 4
  %y = alloca [64 x i32], align 16
  %a = alloca i32, align 4
  %b = alloca i32*, align 8
  %0 = alloca i8, i64 2, align 16
  store i32 32, i32* %a, align 4
  store i32* %a, i32** %b, align 8
  ret void
}