| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 1 | ; RUN: opt -inline %s -S | FileCheck %s |
| 2 | ; Ensure SSP attributes are propagated correctly when inlining. |
| 3 | |
| 4 | @.str = private unnamed_addr constant [11 x i8] c"fun_nossp\0A\00", align 1 |
| 5 | @.str1 = private unnamed_addr constant [9 x i8] c"fun_ssp\0A\00", align 1 |
| 6 | @.str2 = private unnamed_addr constant [15 x i8] c"fun_sspstrong\0A\00", align 1 |
| 7 | @.str3 = private unnamed_addr constant [12 x i8] c"fun_sspreq\0A\00", align 1 |
| 8 | |
| 9 | ; These first four functions (@fun_sspreq, @fun_sspstrong, @fun_ssp, @fun_nossp) |
| 10 | ; are used by the remaining functions to ensure that the SSP attributes are |
| 11 | ; propagated correctly. The caller should have its SSP attribute set as: |
| 12 | ; strictest(caller-ssp-attr, callee-ssp-attr), where strictness is ordered as: |
| 13 | ; sspreq > sspstrong > ssp > [no ssp] |
| Bill Wendling | 1c7cc8a | 2013-01-31 23:16:25 +0000 | [diff] [blame] | 14 | define internal void @fun_sspreq() nounwind sspreq uwtable { |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 15 | entry: |
| David Blaikie | 23af648 | 2015-04-16 23:24:18 +0000 | [diff] [blame] | 16 | %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str3, i32 0, i32 0)) |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 17 | ret void |
| 18 | } |
| 19 | |
| Bill Wendling | 1c7cc8a | 2013-01-31 23:16:25 +0000 | [diff] [blame] | 20 | define internal void @fun_sspstrong() nounwind sspstrong uwtable { |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 21 | entry: |
| David Blaikie | 23af648 | 2015-04-16 23:24:18 +0000 | [diff] [blame] | 22 | %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str2, i32 0, i32 0)) |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 23 | ret void |
| 24 | } |
| 25 | |
| Bill Wendling | 1c7cc8a | 2013-01-31 23:16:25 +0000 | [diff] [blame] | 26 | define internal void @fun_ssp() nounwind ssp uwtable { |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 27 | entry: |
| David Blaikie | 23af648 | 2015-04-16 23:24:18 +0000 | [diff] [blame] | 28 | %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str1, i32 0, i32 0)) |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 29 | ret void |
| 30 | } |
| 31 | |
| 32 | define internal void @fun_nossp() nounwind uwtable { |
| 33 | entry: |
| David Blaikie | 23af648 | 2015-04-16 23:24:18 +0000 | [diff] [blame] | 34 | %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0)) |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 35 | ret void |
| 36 | } |
| 37 | |
| 38 | ; Tests start below |
| 39 | |
| Bill Wendling | 1c7cc8a | 2013-01-31 23:16:25 +0000 | [diff] [blame] | 40 | define void @inline_req_req() nounwind sspreq uwtable { |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 41 | entry: |
| Bill Wendling | 90bc19c | 2013-02-20 07:21:42 +0000 | [diff] [blame] | 42 | ; CHECK: @inline_req_req() #0 |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 43 | call void @fun_sspreq() |
| 44 | ret void |
| 45 | } |
| 46 | |
| Bill Wendling | 1c7cc8a | 2013-01-31 23:16:25 +0000 | [diff] [blame] | 47 | define void @inline_req_strong() nounwind sspstrong uwtable { |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 48 | entry: |
| Bill Wendling | 90bc19c | 2013-02-20 07:21:42 +0000 | [diff] [blame] | 49 | ; CHECK: @inline_req_strong() #0 |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 50 | call void @fun_sspreq() |
| 51 | ret void |
| 52 | } |
| 53 | |
| Bill Wendling | 1c7cc8a | 2013-01-31 23:16:25 +0000 | [diff] [blame] | 54 | define void @inline_req_ssp() nounwind ssp uwtable { |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 55 | entry: |
| Bill Wendling | 90bc19c | 2013-02-20 07:21:42 +0000 | [diff] [blame] | 56 | ; CHECK: @inline_req_ssp() #0 |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 57 | call void @fun_sspreq() |
| 58 | ret void |
| 59 | } |
| 60 | |
| 61 | define void @inline_req_nossp() nounwind uwtable { |
| 62 | entry: |
| Bill Wendling | 90bc19c | 2013-02-20 07:21:42 +0000 | [diff] [blame] | 63 | ; CHECK: @inline_req_nossp() #0 |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 64 | call void @fun_sspreq() |
| 65 | ret void |
| 66 | } |
| 67 | |
| Bill Wendling | 1c7cc8a | 2013-01-31 23:16:25 +0000 | [diff] [blame] | 68 | define void @inline_strong_req() nounwind sspreq uwtable { |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 69 | entry: |
| Bill Wendling | 90bc19c | 2013-02-20 07:21:42 +0000 | [diff] [blame] | 70 | ; CHECK: @inline_strong_req() #0 |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 71 | call void @fun_sspstrong() |
| 72 | ret void |
| 73 | } |
| 74 | |
| 75 | |
| Bill Wendling | 1c7cc8a | 2013-01-31 23:16:25 +0000 | [diff] [blame] | 76 | define void @inline_strong_strong() nounwind sspstrong uwtable { |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 77 | entry: |
| Bill Wendling | 90bc19c | 2013-02-20 07:21:42 +0000 | [diff] [blame] | 78 | ; CHECK: @inline_strong_strong() #1 |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 79 | call void @fun_sspstrong() |
| 80 | ret void |
| 81 | } |
| 82 | |
| Bill Wendling | 1c7cc8a | 2013-01-31 23:16:25 +0000 | [diff] [blame] | 83 | define void @inline_strong_ssp() nounwind ssp uwtable { |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 84 | entry: |
| Bill Wendling | 90bc19c | 2013-02-20 07:21:42 +0000 | [diff] [blame] | 85 | ; CHECK: @inline_strong_ssp() #1 |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 86 | call void @fun_sspstrong() |
| 87 | ret void |
| 88 | } |
| 89 | |
| 90 | define void @inline_strong_nossp() nounwind uwtable { |
| 91 | entry: |
| Bill Wendling | 90bc19c | 2013-02-20 07:21:42 +0000 | [diff] [blame] | 92 | ; CHECK: @inline_strong_nossp() #1 |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 93 | call void @fun_sspstrong() |
| 94 | ret void |
| 95 | } |
| 96 | |
| Bill Wendling | 1c7cc8a | 2013-01-31 23:16:25 +0000 | [diff] [blame] | 97 | define void @inline_ssp_req() nounwind sspreq uwtable { |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 98 | entry: |
| Bill Wendling | 90bc19c | 2013-02-20 07:21:42 +0000 | [diff] [blame] | 99 | ; CHECK: @inline_ssp_req() #0 |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 100 | call void @fun_ssp() |
| 101 | ret void |
| 102 | } |
| 103 | |
| 104 | |
| Bill Wendling | 1c7cc8a | 2013-01-31 23:16:25 +0000 | [diff] [blame] | 105 | define void @inline_ssp_strong() nounwind sspstrong uwtable { |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 106 | entry: |
| Bill Wendling | 90bc19c | 2013-02-20 07:21:42 +0000 | [diff] [blame] | 107 | ; CHECK: @inline_ssp_strong() #1 |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 108 | call void @fun_ssp() |
| 109 | ret void |
| 110 | } |
| 111 | |
| Bill Wendling | 1c7cc8a | 2013-01-31 23:16:25 +0000 | [diff] [blame] | 112 | define void @inline_ssp_ssp() nounwind ssp uwtable { |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 113 | entry: |
| Bill Wendling | 90bc19c | 2013-02-20 07:21:42 +0000 | [diff] [blame] | 114 | ; CHECK: @inline_ssp_ssp() #2 |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 115 | call void @fun_ssp() |
| 116 | ret void |
| 117 | } |
| 118 | |
| 119 | define void @inline_ssp_nossp() nounwind uwtable { |
| 120 | entry: |
| Bill Wendling | 90bc19c | 2013-02-20 07:21:42 +0000 | [diff] [blame] | 121 | ; CHECK: @inline_ssp_nossp() #2 |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 122 | call void @fun_ssp() |
| 123 | ret void |
| 124 | } |
| 125 | |
| 126 | define void @inline_nossp_req() nounwind uwtable sspreq { |
| 127 | entry: |
| Bill Wendling | 90bc19c | 2013-02-20 07:21:42 +0000 | [diff] [blame] | 128 | ; CHECK: @inline_nossp_req() #0 |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 129 | call void @fun_nossp() |
| 130 | ret void |
| 131 | } |
| 132 | |
| 133 | |
| Bill Wendling | 1c7cc8a | 2013-01-31 23:16:25 +0000 | [diff] [blame] | 134 | define void @inline_nossp_strong() nounwind sspstrong uwtable { |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 135 | entry: |
| Bill Wendling | 90bc19c | 2013-02-20 07:21:42 +0000 | [diff] [blame] | 136 | ; CHECK: @inline_nossp_strong() #1 |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 137 | call void @fun_nossp() |
| 138 | ret void |
| 139 | } |
| 140 | |
| Bill Wendling | 1c7cc8a | 2013-01-31 23:16:25 +0000 | [diff] [blame] | 141 | define void @inline_nossp_ssp() nounwind ssp uwtable { |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 142 | entry: |
| Bill Wendling | 90bc19c | 2013-02-20 07:21:42 +0000 | [diff] [blame] | 143 | ; CHECK: @inline_nossp_ssp() #2 |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 144 | call void @fun_nossp() |
| 145 | ret void |
| 146 | } |
| 147 | |
| 148 | define void @inline_nossp_nossp() nounwind uwtable { |
| 149 | entry: |
| Bill Wendling | 90bc19c | 2013-02-20 07:21:42 +0000 | [diff] [blame] | 150 | ; CHECK: @inline_nossp_nossp() #3 |
| Bill Wendling | d154e283 | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 151 | call void @fun_nossp() |
| 152 | ret void |
| 153 | } |
| 154 | |
| 155 | declare i32 @printf(i8*, ...) |
| Bill Wendling | 90bc19c | 2013-02-20 07:21:42 +0000 | [diff] [blame] | 156 | |
| 157 | ; CHECK: attributes #0 = { nounwind sspreq uwtable } |
| 158 | ; CHECK: attributes #1 = { nounwind sspstrong uwtable } |
| 159 | ; CHECK: attributes #2 = { nounwind ssp uwtable } |
| 160 | ; CHECK: attributes #3 = { nounwind uwtable } |