if base.Debug.PGOInline >= 2 {
ir.VisitFuncsBottomUp(decls, func(list []*ir.Func, recursive bool) {
for _, f := range list {
- name := ir.PkgFuncName(f)
+ name := ir.LinkFuncName(f)
if n, ok := p.WeightedCG.IRNodes[name]; ok {
p.RedirectEdges(n, inlinedCallSites)
}
// Update the budget for profile-guided inlining.
budget := int32(inlineMaxBudget)
if profile != nil {
- if n, ok := profile.WeightedCG.IRNodes[ir.PkgFuncName(fn)]; ok {
+ if n, ok := profile.WeightedCG.IRNodes[ir.LinkFuncName(fn)]; ok {
if _, ok := candHotCalleeMap[n]; ok {
budget = int32(inlineHotMaxBudget)
if base.Debug.PGOInline > 0 {
"cmd/compile/internal/base"
"cmd/compile/internal/types"
"cmd/internal/obj"
+ "cmd/internal/objabi"
"cmd/internal/src"
"fmt"
)
}
}
-// FuncName returns the name (without the package) of the function n.
+// FuncName returns the name (without the package) of the function f.
func FuncName(f *Func) string {
if f == nil || f.Nname == nil {
return "<nil>"
return f.Sym().Name
}
-// PkgFuncName returns the name of the function referenced by n, with package prepended.
-// This differs from the compiler's internal convention where local functions lack a package
-// because the ultimate consumer of this is a human looking at an IDE; package is only empty
-// if the compilation package is actually the empty string.
+// PkgFuncName returns the name of the function referenced by f, with package
+// prepended.
+//
+// This differs from the compiler's internal convention where local functions
+// lack a package. This is primarily useful when the ultimate consumer of this
+// is a human looking at message.
func PkgFuncName(f *Func) string {
if f == nil || f.Nname == nil {
return "<nil>"
return pkg.Path + "." + s.Name
}
+// LinkFuncName returns the name of the function f, as it will appear in the
+// symbol table of the final linked binary.
+func LinkFuncName(f *Func) string {
+ if f == nil || f.Nname == nil {
+ return "<nil>"
+ }
+ s := f.Sym()
+ pkg := s.Pkg
+
+ return objabi.PathToPrefix(pkg.Path) + "." + s.Name
+}
+
// IsEqOrHashFunc reports whether f is type eq/hash function.
func IsEqOrHashFunc(f *Func) bool {
if f == nil || f.Nname == nil {
if g.InEdges == nil {
g.InEdges = make(map[*IRNode][]*IREdge)
}
- name := ir.PkgFuncName(fn)
+ name := ir.LinkFuncName(fn)
node := new(IRNode)
node.AST = fn
if g.IRNodes[name] == nil {
// Create an IRNode for the callee.
calleenode := new(IRNode)
calleenode.AST = callee
- calleename := ir.PkgFuncName(callee)
+ calleename := ir.LinkFuncName(callee)
// Create key for NodeMapKey.
nodeinfo := NodeMapKey{
funcs := make(map[string]struct{})
ir.VisitFuncsBottomUp(typecheck.Target.Decls, func(list []*ir.Func, recursive bool) {
for _, f := range list {
- name := ir.PkgFuncName(f)
+ name := ir.LinkFuncName(f)
funcs[name] = struct{}{}
}
})
for name := range funcs {
if n, ok := p.WeightedCG.IRNodes[name]; ok {
for _, e := range p.WeightedCG.OutEdges[n] {
- if _, ok := nodes[ir.PkgFuncName(e.Src.AST)]; !ok {
- nodes[ir.PkgFuncName(e.Src.AST)] = e.Src.AST
+ if _, ok := nodes[ir.LinkFuncName(e.Src.AST)]; !ok {
+ nodes[ir.LinkFuncName(e.Src.AST)] = e.Src.AST
}
- if _, ok := nodes[ir.PkgFuncName(e.Dst.AST)]; !ok {
- nodes[ir.PkgFuncName(e.Dst.AST)] = e.Dst.AST
+ if _, ok := nodes[ir.LinkFuncName(e.Dst.AST)]; !ok {
+ nodes[ir.LinkFuncName(e.Dst.AST)] = e.Dst.AST
}
}
- if _, ok := nodes[ir.PkgFuncName(n.AST)]; !ok {
- nodes[ir.PkgFuncName(n.AST)] = n.AST
+ if _, ok := nodes[ir.LinkFuncName(n.AST)]; !ok {
+ nodes[ir.LinkFuncName(n.AST)] = n.AST
}
}
}
nodeweight := WeightInPercentage(n.Flat, p.TotalNodeWeight)
color := "black"
if ast.Inl != nil {
- fmt.Printf("\"%v\" [color=%v,label=\"%v,freq=%.2f,inl_cost=%d\"];\n", ir.PkgFuncName(ast), color, ir.PkgFuncName(ast), nodeweight, ast.Inl.Cost)
+ fmt.Printf("\"%v\" [color=%v,label=\"%v,freq=%.2f,inl_cost=%d\"];\n", ir.LinkFuncName(ast), color, ir.LinkFuncName(ast), nodeweight, ast.Inl.Cost)
} else {
- fmt.Printf("\"%v\" [color=%v, label=\"%v,freq=%.2f\"];\n", ir.PkgFuncName(ast), color, ir.PkgFuncName(ast), nodeweight)
+ fmt.Printf("\"%v\" [color=%v, label=\"%v,freq=%.2f\"];\n", ir.LinkFuncName(ast), color, ir.LinkFuncName(ast), nodeweight)
}
}
}
// Print edges.
ir.VisitFuncsBottomUp(typecheck.Target.Decls, func(list []*ir.Func, recursive bool) {
for _, f := range list {
- name := ir.PkgFuncName(f)
+ name := ir.LinkFuncName(f)
if n, ok := p.WeightedCG.IRNodes[name]; ok {
for _, e := range p.WeightedCG.OutEdges[n] {
edgepercent := WeightInPercentage(e.Weight, p.TotalEdgeWeight)
fmt.Printf("edge [color=black, style=solid];\n")
}
- fmt.Printf("\"%v\" -> \"%v\" [label=\"%.2f\"];\n", ir.PkgFuncName(n.AST), ir.PkgFuncName(e.Dst.AST), edgepercent)
+ fmt.Printf("\"%v\" -> \"%v\" [label=\"%.2f\"];\n", ir.LinkFuncName(n.AST), ir.LinkFuncName(e.Dst.AST), edgepercent)
}
}
}