]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: don’t generate pointless gotos during inlining
authorJosh Bleecher Snyder <josharian@gmail.com>
Fri, 27 May 2016 22:33:11 +0000 (15:33 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Sun, 21 Aug 2016 23:18:33 +0000 (23:18 +0000)
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>

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

index fc0003da816af4342870d43f61d336605fb45787..e86875d95c90d7d36d5921f0daff9f6c2f2354dc 100644 (file)
@@ -217,6 +217,9 @@ func newlab(n *Node) *Label {
                lab = new(Label)
                lab.Sym = s
                s.Label = lab
+               if n.Used {
+                       lab.Used = true
+               }
                labellist = append(labellist, lab)
        }
 
index a669df819f803368b310043e2228a737955358b5..8245a73791d0bed67b002e71d63706f18e185518 100644 (file)
@@ -778,8 +778,9 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
 
        body := subst.list(fn.Func.Inl)
 
-       body = append(body, Nod(OGOTO, retlabel, nil)) // avoid 'not used' when function doesn't have return
-       body = append(body, Nod(OLABEL, retlabel, nil))
+       lab := Nod(OLABEL, retlabel, nil)
+       lab.Used = true // avoid 'not used' when function doesn't have return
+       body = append(body, lab)
 
        typecheckslice(body, Etop)
 
index 304f446df1d45afb33cdd09238368c5f517d1960..e801f2ce289b5148f6a2445db0328b84402d170d 100644 (file)
@@ -193,7 +193,7 @@ func buildssa(fn *Node) *ssa.Func {
 
        // Check that we used all labels
        for name, lab := range s.labels {
-               if !lab.used() && !lab.reported {
+               if !lab.used() && !lab.reported && !lab.defNode.Used {
                        yyerrorl(lab.defNode.Lineno, "label %v defined and not used", name)
                        lab.reported = true
                }