]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: reduce garbage from autolabel
authorJosh Bleecher Snyder <josharian@gmail.com>
Tue, 16 Aug 2016 04:09:39 +0000 (21:09 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 16 Aug 2016 04:29:32 +0000 (04:29 +0000)
Follow-up to CL 26661

Change-Id: I67c58d17313094675cf0f30ce50d486818ae0dcb
Reviewed-on: https://go-review.googlesource.com/27113
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/inl.go
src/cmd/compile/internal/gc/subr.go
src/cmd/compile/internal/gc/swt.go

index ea49ae16aa0135f8e892bafb09ea5e4e47d631a6..a669df819f803368b310043e2228a737955358b5 100644 (file)
@@ -766,7 +766,7 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
                ninit.Append(as)
        }
 
-       retlabel := autolabel("i")
+       retlabel := autolabel(".i")
        retlabel.Etype = 1 // flag 'safe' for escape analysis (no backjumps)
 
        inlgen++
index fa4c8e8ba1a3429bcfaef683f5cda3281a15e5df..c3f2b605099ffbad36b48fb9ba1775d0f2afc22f 100644 (file)
@@ -248,16 +248,21 @@ func LookupN(prefix string, n int) *Sym {
 
 // autolabel generates a new Name node for use with
 // an automatically generated label.
-// prefix is a short mnemonic (e.g. "s" for switch)
+// prefix is a short mnemonic (e.g. ".s" for switch)
 // to help with debugging.
+// It should begin with "." to avoid conflicts with
+// user labels.
 func autolabel(prefix string) *Node {
+       if prefix[0] != '.' {
+               Fatalf("autolabel prefix must start with '.', have %q", prefix)
+       }
        fn := Curfn
        if Curfn == nil {
                Fatalf("autolabel outside function")
        }
        n := fn.Func.Label
        fn.Func.Label++
-       return newname(LookupN("."+prefix, int(n)))
+       return newname(LookupN(prefix, int(n)))
 }
 
 var initSyms []*Sym
index dce3e16ce164a4648021ef0aae5625f900acb637..f44c747d366436512081c1fcea329129c105f776 100644 (file)
@@ -358,7 +358,7 @@ func casebody(sw *Node, typeswvar *Node) {
                n.Op = OCASE
                needvar := n.List.Len() != 1 || n.List.First().Op == OLITERAL
 
-               jmp := Nod(OGOTO, autolabel("s"), nil)
+               jmp := Nod(OGOTO, autolabel(".s"), nil)
                if n.List.Len() == 0 {
                        if def != nil {
                                Yyerror("more than one default case")
@@ -577,7 +577,7 @@ func (s *typeSwitch) walk(sw *Node) {
                i.Nbody.Set1(typenil)
        } else {
                // Jump to default case.
-               lbl := autolabel("s")
+               lbl := autolabel(".s")
                i.Nbody.Set1(Nod(OGOTO, lbl, nil))
                // Wrap default case with label.
                blk := Nod(OBLOCK, nil, nil)