1
0
mirror of https://github.com/golang/go synced 2024-11-17 21:24:55 -07:00

cmd/compile/internal/pgo: remove some unused fields

We intentionally don't use file path so it is resilient to code
moving. OrigName and Objfile are also not used currently. Remove
them. (We can add them back if it turns out to be useful.)

Change-Id: I7975d78c874bc21475b9119301088452a4426cb9
Reviewed-on: https://go-review.googlesource.com/c/go/+/447801
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Cherry Mui 2022-11-03 20:33:34 -04:00
parent 1a4cc091a9
commit a72e133422

View File

@ -21,7 +21,6 @@ import (
"fmt" "fmt"
"internal/profile" "internal/profile"
"math" "math"
"path/filepath"
"sort" "sort"
"strings" "strings"
) )
@ -30,9 +29,6 @@ import (
type Options struct { type Options struct {
SampleValue func(s []int64) int64 // Function to compute the value of a sample SampleValue func(s []int64) int64 // Function to compute the value of a sample
SampleMeanDivisor func(s []int64) int64 // Function to compute the divisor for mean graphs, or nil SampleMeanDivisor func(s []int64) int64 // Function to compute the divisor for mean graphs, or nil
FormatTag func(int64, string) string // Function to format a sample tag value into a string
ObjNames bool // Always preserve obj filename
OrigFnNames bool // Preserve original (eg mangled) function names
CallTree bool // Build a tree instead of a graph CallTree bool // Build a tree instead of a graph
DropNegative bool // Drop nodes with overall negative values DropNegative bool // Drop nodes with overall negative values
@ -122,11 +118,11 @@ func (n *Node) AddToEdgeDiv(to *Node, dv, v int64, residual, inline bool) {
// NodeInfo contains the attributes for a node. // NodeInfo contains the attributes for a node.
type NodeInfo struct { type NodeInfo struct {
Name string Name string
OrigName string
Address uint64 Address uint64
File string
StartLine, Lineno int StartLine, Lineno int
Objfile string //File string
//OrigName string
//Objfile string
} }
// PrintableName calls the Node's Formatter function with a single space separator. // PrintableName calls the Node's Formatter function with a single space separator.
@ -147,15 +143,9 @@ func (i *NodeInfo) NameComponents() []string {
switch { switch {
case i.Lineno != 0: case i.Lineno != 0:
// User requested line numbers, provide what we have. // User requested line numbers, provide what we have.
name = append(name, fmt.Sprintf("%s:%d", i.File, i.Lineno)) name = append(name, fmt.Sprintf(":%d", i.Lineno))
case i.File != "":
// User requested file name, provide it.
name = append(name, i.File)
case i.Name != "": case i.Name != "":
// User requested function name. It was already included. // User requested function name. It was already included.
case i.Objfile != "":
// Only binary name is available
name = append(name, "["+filepath.Base(i.Objfile)+"]")
default: default:
// Do not leave it empty if there is no information at all. // Do not leave it empty if there is no information at all.
name = append(name, "<unknown>") name = append(name, "<unknown>")
@ -284,6 +274,7 @@ func newGraph(prof *profile.Profile, o *Options) (*Graph, map[uint64]Nodes) {
seenEdge[nodePair{n, parent}] = true seenEdge[nodePair{n, parent}] = true
parent.AddToEdgeDiv(n, dw, w, residual, ni != len(locNodes)-1) parent.AddToEdgeDiv(n, dw, w, residual, ni != len(locNodes)-1)
} }
parent = n parent = n
residual = false residual = false
} }
@ -422,23 +413,14 @@ func (nm NodeMap) findOrInsertLine(l *profile.Location, li profile.Line, o *Opti
func nodeInfo(l *profile.Location, line profile.Line, objfile string, o *Options) *NodeInfo { func nodeInfo(l *profile.Location, line profile.Line, objfile string, o *Options) *NodeInfo {
if line.Function == nil { if line.Function == nil {
return &NodeInfo{Address: l.Address, Objfile: objfile} return &NodeInfo{Address: l.Address}
} }
ni := &NodeInfo{ ni := &NodeInfo{
Address: l.Address, Address: l.Address,
Lineno: int(line.Line), Lineno: int(line.Line),
Name: line.Function.Name, Name: line.Function.Name,
} }
if fname := line.Function.Filename; fname != "" {
ni.File = filepath.Clean(fname)
}
if o.OrigFnNames {
ni.OrigName = line.Function.SystemName
}
if o.ObjNames || (ni.Name == "" && ni.OrigName == "") {
ni.Objfile = objfile
ni.StartLine = int(line.Function.StartLine) ni.StartLine = int(line.Function.StartLine)
}
return ni return ni
} }
@ -639,9 +621,6 @@ func (ns Nodes) Sort(o NodeOrder) error {
case FileOrder: case FileOrder:
s = nodeSorter{ns, s = nodeSorter{ns,
func(l, r *Node) bool { func(l, r *Node) bool {
if iv, jv := l.Info.File, r.Info.File; iv != jv {
return iv < jv
}
if iv, jv := l.Info.StartLine, r.Info.StartLine; iv != jv { if iv, jv := l.Info.StartLine, r.Info.StartLine; iv != jv {
return iv < jv return iv < jv
} }