Skip to content

Commit d1faf38

Browse files
committed
cmd/compile: don’t generate pointless gotos during inlining
Their only purpose in life was to suppress an error. Suppress that error explicitly instead by reusing an existing, aptly named Node field. This generates fewer blocks during ssa construction. name old alloc/op new alloc/op delta Template 47.5MB ± 0% 47.2MB ± 0% -0.72% (p=0.000 n=15+15) Unicode 36.8MB ± 0% 36.8MB ± 0% ~ (p=0.775 n=15+15) GoTypes 143MB ± 0% 142MB ± 0% -1.03% (p=0.000 n=15+14) Compiler 686MB ± 0% 674MB ± 0% -1.75% (p=0.000 n=15+15) name old allocs/op new allocs/op delta Template 446k ± 0% 445k ± 0% -0.20% (p=0.000 n=15+15) Unicode 355k ± 0% 355k ± 0% ~ (p=0.235 n=13+15) GoTypes 1.36M ± 0% 1.36M ± 0% -0.41% (p=0.000 n=13+15) Compiler 5.77M ± 0% 5.70M ± 0% -1.16% (p=0.000 n=15+15) Change-Id: I5f14afb833c9d355688d9a229eb820e95c7657bf Reviewed-on: https://go-review.googlesource.com/27461 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
1 parent 16e3ce2 commit d1faf38

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/cmd/compile/internal/gc/gen.go

+3
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ func newlab(n *Node) *Label {
217217
lab = new(Label)
218218
lab.Sym = s
219219
s.Label = lab
220+
if n.Used {
221+
lab.Used = true
222+
}
220223
labellist = append(labellist, lab)
221224
}
222225

src/cmd/compile/internal/gc/inl.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,9 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
778778

779779
body := subst.list(fn.Func.Inl)
780780

781-
body = append(body, Nod(OGOTO, retlabel, nil)) // avoid 'not used' when function doesn't have return
782-
body = append(body, Nod(OLABEL, retlabel, nil))
781+
lab := Nod(OLABEL, retlabel, nil)
782+
lab.Used = true // avoid 'not used' when function doesn't have return
783+
body = append(body, lab)
783784

784785
typecheckslice(body, Etop)
785786

src/cmd/compile/internal/gc/ssa.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func buildssa(fn *Node) *ssa.Func {
193193

194194
// Check that we used all labels
195195
for name, lab := range s.labels {
196-
if !lab.used() && !lab.reported {
196+
if !lab.used() && !lab.reported && !lab.defNode.Used {
197197
yyerrorl(lab.defNode.Lineno, "label %v defined and not used", name)
198198
lab.reported = true
199199
}

0 commit comments

Comments
 (0)