ninit.Append(as)
}
- retlabel := newlabel_inl()
+ retlabel := autolabel("i")
+ retlabel.Etype = 1 // flag 'safe' for escape analysis (no backjumps)
+
inlgen++
subst := inlsubst{
return n
}
-var newlabel_inl_label int
-
-func newlabel_inl() *Node {
- newlabel_inl_label++
- n := newname(LookupN(".inlret", newlabel_inl_label))
- n.Etype = 1 // flag 'safe' for escape analysis (no backjumps)
- return n
-}
-
// The inlsubst type implements the actual inlining of a single
// function call.
type inlsubst struct {
return LookupBytes(b)
}
+// autolabel generates a new Name node for use with
+// an automatically generated label.
+// prefix is a short mnemonic (e.g. "s" for switch)
+// to help with debugging.
+func autolabel(prefix string) *Node {
+ fn := Curfn
+ if Curfn == nil {
+ Fatalf("autolabel outside function")
+ }
+ n := fn.Func.Label
+ fn.Func.Label++
+ return newname(LookupN("."+prefix, int(n)))
+}
+
var initSyms []*Sym
var nopkg = &Pkg{
package gc
-import (
- "sort"
- "strconv"
-)
+import "sort"
const (
// expression switch
n.Op = OCASE
needvar := n.List.Len() != 1 || n.List.First().Op == OLITERAL
- jmp := Nod(OGOTO, newCaseLabel(), nil)
+ jmp := Nod(OGOTO, autolabel("s"), nil)
if n.List.Len() == 0 {
if def != nil {
Yyerror("more than one default case")
lineno = lno
}
-// nSwitchLabel is the number of switch labels generated.
-// This should be per-function, but it is a global counter for now.
-var nSwitchLabel int
-
-func newCaseLabel() *Node {
- label := strconv.Itoa(nSwitchLabel)
- nSwitchLabel++
- return newname(Lookup(label))
-}
-
// caseClauses generates a slice of caseClauses
// corresponding to the clauses in the switch statement sw.
// Kind is the kind of switch statement.
i.Nbody.Set1(typenil)
} else {
// Jump to default case.
- lbl := newCaseLabel()
+ lbl := autolabel("s")
i.Nbody.Set1(Nod(OGOTO, lbl, nil))
// Wrap default case with label.
blk := Nod(OBLOCK, nil, nil)