cmd/compile: reduce garbage from autolabel

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>
This commit is contained in:
Josh Bleecher Snyder 2016-08-15 21:09:39 -07:00
parent 77e68ea78a
commit fe27291c00
3 changed files with 10 additions and 5 deletions

View 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