1
0
mirror of https://github.com/golang/go synced 2024-11-18 15:24:41 -07:00

cmd/compile: add and use gc.Node.funcname

Change-Id: If5631eae7e2ad2bef56e79b82f77105246e68773
Reviewed-on: https://go-review.googlesource.com/41494
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2017-04-23 05:10:21 -07:00
parent d40bb738ff
commit eba396f596
7 changed files with 17 additions and 12 deletions

View File

@ -173,7 +173,7 @@ func closurename(n *Node) *types.Sym {
gen = closurename_closgen gen = closurename_closgen
case n.Func.Outerfunc.Op == ODCLFUNC: case n.Func.Outerfunc.Op == ODCLFUNC:
// The outermost closure inside of a named function. // The outermost closure inside of a named function.
outer = n.Func.Outerfunc.Func.Nname.Sym.Name outer = n.Func.Outerfunc.funcname()
prefix = "func" prefix = "func"

View File

@ -342,8 +342,8 @@ func (p *noder) funcDecl(fun *syntax.FuncDecl) *Node {
lineno = Ctxt.PosTable.XPos(fun.Body.Rbrace) lineno = Ctxt.PosTable.XPos(fun.Body.Rbrace)
f.Func.Endlineno = lineno f.Func.Endlineno = lineno
} else { } else {
if pure_go || strings.HasPrefix(f.Func.Nname.Sym.Name, "init.") { if pure_go || strings.HasPrefix(f.funcname(), "init.") {
yyerrorl(f.Pos, "missing function body for %q", f.Func.Nname.Sym.Name) yyerrorl(f.Pos, "missing function body for %q", f.funcname())
} }
} }

View File

@ -19,10 +19,10 @@ import (
// "Portable" code generation. // "Portable" code generation.
func emitptrargsmap() { func emitptrargsmap() {
if Curfn.Func.Nname.Sym.Name == "_" { if Curfn.funcname() == "_" {
return return
} }
sym := lookup(fmt.Sprintf("%s.args_stackmap", Curfn.Func.Nname.Sym.Name)) sym := lookup(fmt.Sprintf("%s.args_stackmap", Curfn.funcname()))
lsym := sym.Linksym() lsym := sym.Linksym()
nptr := int(Curfn.Type.ArgWidth() / int64(Widthptr)) nptr := int(Curfn.Type.ArgWidth() / int64(Widthptr))

View File

@ -819,13 +819,13 @@ func (lv *Liveness) clobber() {
// Clobber only functions where the hash of the function name matches a pattern. // Clobber only functions where the hash of the function name matches a pattern.
// Useful for binary searching for a miscompiled function. // Useful for binary searching for a miscompiled function.
hstr := "" hstr := ""
for _, b := range sha1.Sum([]byte(lv.fn.Func.Nname.Sym.Name)) { for _, b := range sha1.Sum([]byte(lv.fn.funcname())) {
hstr += fmt.Sprintf("%08b", b) hstr += fmt.Sprintf("%08b", b)
} }
if !strings.HasSuffix(hstr, h) { if !strings.HasSuffix(hstr, h) {
return return
} }
fmt.Printf("\t\t\tCLOBBERDEAD %s\n", lv.fn.Func.Nname.Sym.Name) fmt.Printf("\t\t\tCLOBBERDEAD %s\n", lv.fn.funcname())
} }
if lv.f.Name == "forkAndExecInChild" { if lv.f.Name == "forkAndExecInChild" {
// forkAndExecInChild calls vfork (on linux/amd64, anyway). // forkAndExecInChild calls vfork (on linux/amd64, anyway).
@ -1087,7 +1087,7 @@ Outer:
} }
func (lv *Liveness) showlive(v *ssa.Value, live bvec) { func (lv *Liveness) showlive(v *ssa.Value, live bvec) {
if debuglive == 0 || lv.fn.Func.Nname.Sym.Name == "init" || strings.HasPrefix(lv.fn.Func.Nname.Sym.Name, ".") { if debuglive == 0 || lv.fn.funcname() == "init" || strings.HasPrefix(lv.fn.funcname(), ".") {
return return
} }
if live.IsEmpty() { if live.IsEmpty() {
@ -1101,7 +1101,7 @@ func (lv *Liveness) showlive(v *ssa.Value, live bvec) {
s := "live at " s := "live at "
if v == nil { if v == nil {
s += fmt.Sprintf("entry to %s:", lv.fn.Func.Nname.Sym.Name) s += fmt.Sprintf("entry to %s:", lv.fn.funcname())
} else if sym, ok := v.Aux.(*obj.LSym); ok { } else if sym, ok := v.Aux.(*obj.LSym); ok {
fn := sym.Name fn := sym.Name
if pos := strings.Index(fn, "."); pos >= 0 { if pos := strings.Index(fn, "."); pos >= 0 {
@ -1163,7 +1163,7 @@ func (lv *Liveness) printeffect(printed bool, name string, pos int32, x bool) bo
// This format synthesizes the information used during the multiple passes // This format synthesizes the information used during the multiple passes
// into a single presentation. // into a single presentation.
func livenessprintdebug(lv *Liveness) { func livenessprintdebug(lv *Liveness) {
fmt.Printf("liveness: %s\n", lv.fn.Func.Nname.Sym.Name) fmt.Printf("liveness: %s\n", lv.fn.funcname())
pcdata := 0 pcdata := 0
for i, b := range lv.f.Blocks { for i, b := range lv.f.Blocks {

View File

@ -96,7 +96,7 @@ func initssaconfig() {
// buildssa builds an SSA function. // buildssa builds an SSA function.
func buildssa(fn *Node) *ssa.Func { func buildssa(fn *Node) *ssa.Func {
name := fn.Func.Nname.Sym.Name name := fn.funcname()
printssa := name == os.Getenv("GOSSAFUNC") printssa := name == os.Getenv("GOSSAFUNC")
if printssa { if printssa {
fmt.Println("generating SSA for", name) fmt.Println("generating SSA for", name)

View File

@ -191,6 +191,11 @@ func (n *Node) mayBeShared() bool {
return false return false
} }
// funcname returns the name of the function n.
func (n *Node) funcname() string {
return n.Func.Nname.Sym.Name
}
// Name holds Node fields used only by named nodes (ONAME, OTYPE, OPACK, OLABEL, some OLITERAL). // Name holds Node fields used only by named nodes (ONAME, OTYPE, OPACK, OLABEL, some OLITERAL).
type Name struct { type Name struct {
Pack *Node // real package for import . names Pack *Node // real package for import . names

View File

@ -1733,7 +1733,7 @@ func ascompatee(op Op, nl, nr []*Node, init *Nodes) []*Node {
var nln, nrn Nodes var nln, nrn Nodes
nln.Set(nl) nln.Set(nl)
nrn.Set(nr) nrn.Set(nr)
Fatalf("error in shape across %+v %v %+v / %d %d [%s]", nln, op, nrn, len(nl), len(nr), Curfn.Func.Nname.Sym.Name) Fatalf("error in shape across %+v %v %+v / %d %d [%s]", nln, op, nrn, len(nl), len(nr), Curfn.funcname())
} }
return nn return nn
} }