David Bozier | 3246aec | 2017-02-28 17:25:38 +0000 | [diff] [blame] | 1 | ; RUN: llc %s -mtriple=x86_64-unknown-unknown -pass-remarks=stack-protector -o /dev/null 2>&1 | FileCheck %s |
David Bozier | 5159968 | 2017-02-28 16:02:37 +0000 | [diff] [blame] | 2 | ; CHECK-NOT: nossp |
| 3 | ; CHECK: function attribute_ssp |
| 4 | ; CHECK-SAME: a function attribute or command-line switch |
| 5 | ; CHECK-NOT: alloca_fixed_small_nossp |
| 6 | ; CHECK: function alloca_fixed_small_ssp |
| 7 | ; CHECK-SAME: a call to alloca or use of a variable length array |
| 8 | ; CHECK: function alloca_fixed_large_ssp |
| 9 | ; CHECK-SAME: a call to alloca or use of a variable length array |
| 10 | ; CHECK: function alloca_variable_ssp |
| 11 | ; CHECK-SAME: a call to alloca or use of a variable length array |
| 12 | ; CHECK: function buffer_ssp |
| 13 | ; CHECK-SAME: a stack allocated buffer or struct containing a buffer |
| 14 | ; CHECK: function struct_ssp |
| 15 | ; CHECK-SAME: a stack allocated buffer or struct containing a buffer |
| 16 | ; CHECK: function address_ssp |
| 17 | ; CHECK-SAME: the address of a local variable being taken |
| 18 | ; CHECK: function multiple_ssp |
| 19 | ; CHECK-SAME: a function attribute or command-line switch |
| 20 | ; CHECK: function multiple_ssp |
| 21 | ; CHECK-SAME: a stack allocated buffer or struct containing a buffer |
| 22 | ; CHECK: function multiple_ssp |
| 23 | ; CHECK-SAME: a stack allocated buffer or struct containing a buffer |
| 24 | ; CHECK: function multiple_ssp |
| 25 | ; CHECK-SAME: the address of a local variable being taken |
| 26 | ; CHECK: function multiple_ssp |
| 27 | ; CHECK-SAME: a call to alloca or use of a variable length array |
| 28 | |
| 29 | ; Check that no remark is emitted when the switch is not specified. |
David Bozier | 3246aec | 2017-02-28 17:25:38 +0000 | [diff] [blame] | 30 | ; RUN: llc %s -mtriple=x86_64-unknown-unknown -o /dev/null 2>&1 | FileCheck %s -check-prefix=NOREMARK -allow-empty |
David Bozier | 5159968 | 2017-02-28 16:02:37 +0000 | [diff] [blame] | 31 | ; NOREMARK-NOT: ssp |
| 32 | |
Adam Nemet | 5361b82 | 2017-03-09 06:10:27 +0000 | [diff] [blame] | 33 | ; RUN: llc %s -mtriple=x86_64-unknown-unknown -o /dev/null -pass-remarks-output=%t.yaml |
| 34 | ; RUN: cat %t.yaml | FileCheck %s -check-prefix=YAML |
| 35 | ; YAML: --- !Passed |
| 36 | ; YAML-NEXT: Pass: stack-protector |
| 37 | ; YAML-NEXT: Name: StackProtectorRequested |
| 38 | ; YAML-NEXT: Function: attribute_ssp |
| 39 | ; YAML-NEXT: Args: |
| 40 | ; YAML-NEXT: - String: 'Stack protection applied to function ' |
| 41 | ; YAML-NEXT: - Function: attribute_ssp |
| 42 | ; YAML-NEXT: - String: ' due to a function attribute or command-line switch' |
| 43 | ; YAML-NEXT: ... |
| 44 | |
David Bozier | 5159968 | 2017-02-28 16:02:37 +0000 | [diff] [blame] | 45 | define void @nossp() ssp { |
| 46 | ret void |
| 47 | } |
| 48 | |
| 49 | define void @attribute_ssp() sspreq { |
| 50 | ret void |
| 51 | } |
| 52 | |
| 53 | define void @alloca_fixed_small_nossp() ssp { |
| 54 | %1 = alloca i8, i64 2, align 16 |
| 55 | ret void |
| 56 | } |
| 57 | |
| 58 | define void @alloca_fixed_small_ssp() sspstrong { |
| 59 | %1 = alloca i8, i64 2, align 16 |
| 60 | ret void |
| 61 | } |
| 62 | |
| 63 | define void @alloca_fixed_large_ssp() ssp { |
| 64 | %1 = alloca i8, i64 64, align 16 |
| 65 | ret void |
| 66 | } |
| 67 | |
| 68 | define void @alloca_variable_ssp(i64 %x) ssp { |
| 69 | %1 = alloca i8, i64 %x, align 16 |
| 70 | ret void |
| 71 | } |
| 72 | |
| 73 | define void @buffer_ssp() sspstrong { |
| 74 | %x = alloca [64 x i32], align 16 |
| 75 | ret void |
| 76 | } |
| 77 | |
| 78 | %struct.X = type { [64 x i32] } |
| 79 | define void @struct_ssp() sspstrong { |
| 80 | %x = alloca %struct.X, align 4 |
| 81 | ret void |
| 82 | } |
| 83 | |
| 84 | define void @address_ssp() sspstrong { |
| 85 | entry: |
| 86 | %x = alloca i32, align 4 |
| 87 | %y = alloca i32*, align 8 |
| 88 | store i32 32, i32* %x, align 4 |
| 89 | store i32* %x, i32** %y, align 8 |
| 90 | ret void |
| 91 | } |
| 92 | |
| 93 | define void @multiple_ssp() sspreq { |
| 94 | entry: |
| 95 | %x = alloca %struct.X, align 4 |
| 96 | %y = alloca [64 x i32], align 16 |
| 97 | %a = alloca i32, align 4 |
| 98 | %b = alloca i32*, align 8 |
| 99 | %0 = alloca i8, i64 2, align 16 |
| 100 | store i32 32, i32* %a, align 4 |
| 101 | store i32* %a, i32** %b, align 8 |
| 102 | ret void |
| 103 | } |