Skip to content

Commit fe27291

Browse files
committed
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 <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 77e68ea commit fe27291

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
766766
ninit.Append(as)
767767
}
768768

769-
retlabel := autolabel("i")
769+
retlabel := autolabel(".i")
770770
retlabel.Etype = 1 // flag 'safe' for escape analysis (no backjumps)
771771

772772
inlgen++

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,21 @@ func LookupN(prefix string, n int) *Sym {
248248

249249
// autolabel generates a new Name node for use with
250250
// an automatically generated label.
251-
// prefix is a short mnemonic (e.g. "s" for switch)
251+
// prefix is a short mnemonic (e.g. ".s" for switch)
252252
// to help with debugging.
253+
// It should begin with "." to avoid conflicts with
254+
// user labels.
253255
func autolabel(prefix string) *Node {
256+
if prefix[0] != '.' {
257+
Fatalf("autolabel prefix must start with '.', have %q", prefix)
258+
}
254259
fn := Curfn
255260
if Curfn == nil {
256261
Fatalf("autolabel outside function")
257262
}
258263
n := fn.Func.Label
259264
fn.Func.Label++
260-
return newname(LookupN("."+prefix, int(n)))
265+
return newname(LookupN(prefix, int(n)))
261266
}
262267

263268
var initSyms []*Sym

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ func casebody(sw *Node, typeswvar *Node) {
358358
n.Op = OCASE
359359
needvar := n.List.Len() != 1 || n.List.First().Op == OLITERAL
360360

361-
jmp := Nod(OGOTO, autolabel("s"), nil)
361+
jmp := Nod(OGOTO, autolabel(".s"), nil)
362362
if n.List.Len() == 0 {
363363
if def != nil {
364364
Yyerror("more than one default case")
@@ -577,7 +577,7 @@ func (s *typeSwitch) walk(sw *Node) {
577577
i.Nbody.Set1(typenil)
578578
} else {
579579
// Jump to default case.
580-
lbl := autolabel("s")
580+
lbl := autolabel(".s")
581581
i.Nbody.Set1(Nod(OGOTO, lbl, nil))
582582
// Wrap default case with label.
583583
blk := Nod(OBLOCK, nil, nil)

0 commit comments

Comments
 (0)