github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/cmd/compile/inline/inlheur/testdata/props/funcflags.go (about) 1 // Copyright 2023 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // DO NOT EDIT (use 'go test -v -update-expected' instead.) 6 // See github.com/go-asm/go/cmd/compile/inline/inlheur/testdata/props/README.txt 7 // for more information on the format of this file. 8 // <endfilepreamble> 9 10 package funcflags 11 12 import "os" 13 14 // funcflags.go T_simple 20 0 1 15 // Flags FuncPropNeverReturns 16 // <endpropsdump> 17 // {"Flags":1,"ParamFlags":null,"ResultFlags":null} 18 // <endcallsites> 19 // <endfuncpreamble> 20 func T_simple() { 21 panic("bad") 22 } 23 24 // funcflags.go T_nested 32 0 1 25 // Flags FuncPropNeverReturns 26 // ParamFlags 27 // 0 ParamFeedsIfOrSwitch 28 // <endpropsdump> 29 // {"Flags":1,"ParamFlags":[32],"ResultFlags":null} 30 // <endcallsites> 31 // <endfuncpreamble> 32 func T_nested(x int) { 33 if x < 10 { 34 panic("bad") 35 } else { 36 panic("good") 37 } 38 } 39 40 // funcflags.go T_block1 46 0 1 41 // Flags FuncPropNeverReturns 42 // <endpropsdump> 43 // {"Flags":1,"ParamFlags":[0],"ResultFlags":null} 44 // <endcallsites> 45 // <endfuncpreamble> 46 func T_block1(x int) { 47 panic("bad") 48 if x < 10 { 49 return 50 } 51 } 52 53 // funcflags.go T_block2 60 0 1 54 // ParamFlags 55 // 0 ParamFeedsIfOrSwitch 56 // <endpropsdump> 57 // {"Flags":0,"ParamFlags":[32],"ResultFlags":null} 58 // <endcallsites> 59 // <endfuncpreamble> 60 func T_block2(x int) { 61 if x < 10 { 62 return 63 } 64 panic("bad") 65 } 66 67 // funcflags.go T_switches1 75 0 1 68 // Flags FuncPropNeverReturns 69 // ParamFlags 70 // 0 ParamFeedsIfOrSwitch 71 // <endpropsdump> 72 // {"Flags":1,"ParamFlags":[32],"ResultFlags":null} 73 // <endcallsites> 74 // <endfuncpreamble> 75 func T_switches1(x int) { 76 switch x { 77 case 1: 78 panic("one") 79 case 2: 80 panic("two") 81 } 82 panic("whatev") 83 } 84 85 // funcflags.go T_switches1a 92 0 1 86 // ParamFlags 87 // 0 ParamFeedsIfOrSwitch 88 // <endpropsdump> 89 // {"Flags":0,"ParamFlags":[32],"ResultFlags":null} 90 // <endcallsites> 91 // <endfuncpreamble> 92 func T_switches1a(x int) { 93 switch x { 94 case 2: 95 panic("two") 96 } 97 } 98 99 // funcflags.go T_switches2 106 0 1 100 // ParamFlags 101 // 0 ParamFeedsIfOrSwitch 102 // <endpropsdump> 103 // {"Flags":0,"ParamFlags":[32],"ResultFlags":null} 104 // <endcallsites> 105 // <endfuncpreamble> 106 func T_switches2(x int) { 107 switch x { 108 case 1: 109 panic("one") 110 case 2: 111 panic("two") 112 default: 113 return 114 } 115 panic("whatev") 116 } 117 118 // funcflags.go T_switches3 123 0 1 119 // <endpropsdump> 120 // {"Flags":0,"ParamFlags":[0],"ResultFlags":null} 121 // <endcallsites> 122 // <endfuncpreamble> 123 func T_switches3(x interface{}) { 124 switch x.(type) { 125 case bool: 126 panic("one") 127 case float32: 128 panic("two") 129 } 130 } 131 132 // funcflags.go T_switches4 138 0 1 133 // Flags FuncPropNeverReturns 134 // <endpropsdump> 135 // {"Flags":1,"ParamFlags":[0],"ResultFlags":null} 136 // <endcallsites> 137 // <endfuncpreamble> 138 func T_switches4(x int) { 139 switch x { 140 case 1: 141 x++ 142 fallthrough 143 case 2: 144 panic("two") 145 fallthrough 146 default: 147 panic("bad") 148 } 149 panic("whatev") 150 } 151 152 // funcflags.go T_recov 157 0 1 153 // <endpropsdump> 154 // {"Flags":0,"ParamFlags":[0],"ResultFlags":null} 155 // <endcallsites> 156 // <endfuncpreamble> 157 func T_recov(x int) { 158 if x := recover(); x != nil { 159 panic(x) 160 } 161 } 162 163 // funcflags.go T_forloops1 169 0 1 164 // Flags FuncPropNeverReturns 165 // <endpropsdump> 166 // {"Flags":1,"ParamFlags":[0],"ResultFlags":null} 167 // <endcallsites> 168 // <endfuncpreamble> 169 func T_forloops1(x int) { 170 for { 171 panic("wokketa") 172 } 173 } 174 175 // funcflags.go T_forloops2 180 0 1 176 // <endpropsdump> 177 // {"Flags":0,"ParamFlags":[0],"ResultFlags":null} 178 // <endcallsites> 179 // <endfuncpreamble> 180 func T_forloops2(x int) { 181 for { 182 println("blah") 183 if true { 184 break 185 } 186 panic("warg") 187 } 188 } 189 190 // funcflags.go T_forloops3 195 0 1 191 // <endpropsdump> 192 // {"Flags":0,"ParamFlags":[0],"ResultFlags":null} 193 // <endcallsites> 194 // <endfuncpreamble> 195 func T_forloops3(x int) { 196 for i := 0; i < 101; i++ { 197 println("blah") 198 if true { 199 continue 200 } 201 panic("plark") 202 } 203 for i := range [10]int{} { 204 println(i) 205 panic("plark") 206 } 207 panic("whatev") 208 } 209 210 // funcflags.go T_hasgotos 215 0 1 211 // <endpropsdump> 212 // {"Flags":0,"ParamFlags":[0,0],"ResultFlags":null} 213 // <endcallsites> 214 // <endfuncpreamble> 215 func T_hasgotos(x int, y int) { 216 { 217 xx := x 218 panic("bad") 219 lab1: 220 goto lab2 221 lab2: 222 if false { 223 goto lab1 224 } else { 225 goto lab4 226 } 227 lab4: 228 if xx < y { 229 lab3: 230 if false { 231 goto lab3 232 } 233 } 234 println(9) 235 } 236 } 237 238 // funcflags.go T_break_with_label 246 0 1 239 // ParamFlags 240 // 0 ParamMayFeedIfOrSwitch 241 // 1 ParamNoInfo 242 // <endpropsdump> 243 // {"Flags":0,"ParamFlags":[64,0],"ResultFlags":null} 244 // <endcallsites> 245 // <endfuncpreamble> 246 func T_break_with_label(x int, y int) { 247 // presence of break with label should pessimize this func 248 // (similar to goto). 249 panic("bad") 250 lab1: 251 for { 252 println("blah") 253 if x < 0 { 254 break lab1 255 } 256 panic("hubba") 257 } 258 } 259 260 // funcflags.go T_callsexit 268 0 1 261 // Flags FuncPropNeverReturns 262 // ParamFlags 263 // 0 ParamFeedsIfOrSwitch 264 // <endpropsdump> 265 // {"Flags":1,"ParamFlags":[32],"ResultFlags":null} 266 // <endcallsites> 267 // <endfuncpreamble> 268 func T_callsexit(x int) { 269 if x < 0 { 270 os.Exit(1) 271 } 272 os.Exit(2) 273 } 274 275 // funcflags.go T_exitinexpr 281 0 1 276 // <endpropsdump> 277 // {"Flags":0,"ParamFlags":[0],"ResultFlags":null} 278 // callsite: funcflags.go:286:18|0 flagstr "CallSiteOnPanicPath" flagval 2 score 102 mask 1 maskstr "panicPathAdj" 279 // <endcallsites> 280 // <endfuncpreamble> 281 func T_exitinexpr(x int) { 282 // This function does indeed unconditionally call exit, since the 283 // first thing it does is invoke exprcallsexit, however from the 284 // perspective of this function, the call is not at the statement 285 // level, so we'll wind up missing it. 286 if exprcallsexit(x) < 0 { 287 println("foo") 288 } 289 } 290 291 // funcflags.go T_select_noreturn 297 0 1 292 // Flags FuncPropNeverReturns 293 // <endpropsdump> 294 // {"Flags":1,"ParamFlags":[0,0,0],"ResultFlags":null} 295 // <endcallsites> 296 // <endfuncpreamble> 297 func T_select_noreturn(chi chan int, chf chan float32, p *int) { 298 rv := 0 299 select { 300 case i := <-chi: 301 rv = i 302 case f := <-chf: 303 rv = int(f) 304 } 305 *p = rv 306 panic("bad") 307 } 308 309 // funcflags.go T_select_mayreturn 314 0 1 310 // <endpropsdump> 311 // {"Flags":0,"ParamFlags":[0,0,0],"ResultFlags":[0]} 312 // <endcallsites> 313 // <endfuncpreamble> 314 func T_select_mayreturn(chi chan int, chf chan float32, p *int) int { 315 rv := 0 316 select { 317 case i := <-chi: 318 rv = i 319 return i 320 case f := <-chf: 321 rv = int(f) 322 } 323 *p = rv 324 panic("bad") 325 } 326 327 // funcflags.go T_calls_callsexit 334 0 1 328 // Flags FuncPropNeverReturns 329 // <endpropsdump> 330 // {"Flags":1,"ParamFlags":[0],"ResultFlags":null} 331 // callsite: funcflags.go:335:15|0 flagstr "CallSiteOnPanicPath" flagval 2 score 102 mask 1 maskstr "panicPathAdj" 332 // <endcallsites> 333 // <endfuncpreamble> 334 func T_calls_callsexit(x int) { 335 exprcallsexit(x) 336 } 337 338 func exprcallsexit(x int) int { 339 os.Exit(x) 340 return x 341 }