176 lines · plain
1; RUN: opt -passes=inline %s -S | FileCheck %s2; RUN: opt -passes='cgscc(inline)' %s -S | FileCheck %s3; Ensure SSP attributes are propagated correctly when inlining.4 5@.str = private unnamed_addr constant [11 x i8] c"fun_nossp\0A\00", align 16@.str1 = private unnamed_addr constant [9 x i8] c"fun_ssp\0A\00", align 17@.str2 = private unnamed_addr constant [15 x i8] c"fun_sspstrong\0A\00", align 18@.str3 = private unnamed_addr constant [12 x i8] c"fun_sspreq\0A\00", align 19 10; These first four functions (@fun_sspreq, @fun_sspstrong, @fun_ssp, @fun_nossp)11; are used by the remaining functions to ensure that the SSP attributes are12; propagated correctly. If the caller had an SSP attribute before inlining, it13; should have its new SSP attribute set as:14; strictest(caller-ssp-attr, callee-ssp-attr), where strictness is ordered as:15; sspreq > sspstrong > ssp16 17define internal void @fun_sspreq() sspreq {18entry:19 %call = call i32 (ptr, ...) @printf(ptr @.str3)20 ret void21}22 23define internal void @fun_sspreq_alwaysinline() sspreq alwaysinline {24entry:25 %call = call i32 (ptr, ...) @printf(ptr @.str3)26 ret void27}28 29define internal void @fun_sspstrong() sspstrong {30entry:31 %call = call i32 (ptr, ...) @printf(ptr @.str2)32 ret void33}34 35define internal void @fun_ssp() ssp {36entry:37 %call = call i32 (ptr, ...) @printf(ptr @.str1)38 ret void39}40 41define internal void @fun_nossp() {42entry:43 %call = call i32 (ptr, ...) @printf(ptr @.str)44 ret void45}46 47; Tests start below.48 49define void @inline_req_req() sspreq {50entry:51; CHECK: @inline_req_req() #[[SSPREQ:[0-9]]]52 call void @fun_sspreq()53 ret void54}55 56define void @inline_req_strong() sspstrong {57entry:58; CHECK: @inline_req_strong() #[[SSPREQ]]59 call void @fun_sspreq()60 ret void61}62 63define void @inline_req_ssp() ssp {64entry:65; CHECK: @inline_req_ssp() #[[SSPREQ]]66 call void @fun_sspreq()67 ret void68}69 70define void @inline_req_nossp() {71entry:72; CHECK: @inline_req_nossp() {73 call void @fun_sspreq()74 ret void75}76 77define void @alwaysinline_req_nossp() {78entry:79; CHECK: @alwaysinline_req_nossp() {80 call void @fun_sspreq_alwaysinline()81 ret void82}83 84define void @inline_strong_req() sspreq {85entry:86; CHECK: @inline_strong_req() #[[SSPREQ]]87 call void @fun_sspstrong()88 ret void89}90 91 92define void @inline_strong_strong() sspstrong {93entry:94; CHECK: @inline_strong_strong() #[[SSPSTRONG:[0-9]]]95 call void @fun_sspstrong()96 ret void97}98 99define void @inline_strong_ssp() ssp {100entry:101; CHECK: @inline_strong_ssp() #[[SSPSTRONG]]102 call void @fun_sspstrong()103 ret void104}105 106define void @inline_strong_nossp() {107entry:108; CHECK: @inline_strong_nossp() {109 call void @fun_sspstrong()110 ret void111}112 113define void @inline_ssp_req() sspreq {114entry:115; CHECK: @inline_ssp_req() #[[SSPREQ]]116 call void @fun_ssp()117 ret void118}119 120 121define void @inline_ssp_strong() sspstrong {122entry:123; CHECK: @inline_ssp_strong() #[[SSPSTRONG]]124 call void @fun_ssp()125 ret void126}127 128define void @inline_ssp_ssp() ssp {129entry:130; CHECK: @inline_ssp_ssp() #[[SSP:[0-9]]]131 call void @fun_ssp()132 ret void133}134 135define void @inline_ssp_nossp() {136entry:137; CHECK: @inline_ssp_nossp() {138 call void @fun_ssp()139 ret void140}141 142define void @inline_nossp_req() sspreq {143entry:144; CHECK: @inline_nossp_req() #[[SSPREQ]]145 call void @fun_nossp()146 ret void147}148 149 150define void @inline_nossp_strong() sspstrong {151entry:152; CHECK: @inline_nossp_strong() #[[SSPSTRONG]]153 call void @fun_nossp()154 ret void155}156 157define void @inline_nossp_ssp() ssp {158entry:159; CHECK: @inline_nossp_ssp() #[[SSP]]160 call void @fun_nossp()161 ret void162}163 164define void @inline_nossp_nossp() {165entry:166; CHECK: @inline_nossp_nossp() {167 call void @fun_nossp()168 ret void169}170 171declare i32 @printf(ptr, ...)172 173; CHECK: attributes #[[SSPREQ]] = { sspreq }174; CHECK: attributes #[[SSPSTRONG]] = { sspstrong }175; CHECK: attributes #[[SSP]] = { ssp }176