]> Cypherpunks.ru repositories - gostls13.git/blob - test/fixedbugs/issue23521.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / fixedbugs / issue23521.go
1 // errorcheck -0 -m
2
3 // Copyright 2018 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6
7 // Issue 23521: improve early DCE for if without explicit else.
8
9 package p
10
11 //go:noinline
12 func nonleaf() {}
13
14 const truth = true
15
16 func f() int { // ERROR "can inline f"
17         if truth {
18                 return 0
19         }
20         // If everything below is removed, as it should,
21         // function f should be inlineable.
22         nonleaf()
23         for {
24                 panic("")
25         }
26 }
27
28 func g() int { // ERROR "can inline g"
29         return f() // ERROR "inlining call to f"
30 }
31
32 func f2() int { // ERROR "can inline f2"
33         if !truth {
34                 nonleaf()
35         } else {
36                 return 0
37         }
38         panic("")
39 }
40
41 func g2() int { // ERROR "can inline g2"
42         return f2() // ERROR "inlining call to f2"
43 }