LookupFunc looks up a function or method in export data. It is expected to be overridden by package noder, to break a dependency cycle.
var LookupFunc = func(fullName string) (*ir.Func, error) { base.Fatalf("pgoir.LookupMethodFunc not overridden") panic("unreachable") }
PostLookupCleanup performs any remaining cleanup operations needed after a series of calls to LookupFunc, specifically reading in the bodies of functions that may have been delayed due being encountered in a stage where the reader's curfn state was not set up.
var PostLookupCleanup = func() { base.Fatalf("pgoir.PostLookupCleanup not overridden") panic("unreachable") }
func DirectCallee(fn ir.Node) *ir.Func
DirectCallee takes a function-typed expression and returns the underlying function that it refers to if statically known. Otherwise, it returns nil.
Equivalent to inline.inlCallee without calling CanInline on closures.
func NodeLineOffset(n ir.Node, fn *ir.Func) int
NodeLineOffset returns the line offset of n in fn.
CallSiteInfo captures call-site information and its caller/callee.
type CallSiteInfo struct { LineOffset int // Line offset from function start line. Caller *ir.Func Callee *ir.Func }
IREdge represents a call edge in the IRGraph with source, destination, weight, callsite, and line number information.
type IREdge struct { // Source and destination of the edge in IRNode. Src, Dst *IRNode Weight int64 CallSiteOffset int // Line offset from function start line. }
IRGraph is a call graph with nodes pointing to IRs of functions and edges carrying weights and callsite information.
Nodes for indirect calls may have missing IR (IRNode.AST == nil) if the node is not visible from this package (e.g., not in the transitive deps). Keeping these nodes allows determining the hottest edge from a call even if that callee is not available.
TODO(prattmic): Consider merging this data structure with Graph. This is effectively a copy of Graph aggregated to line number and pointing to IR.
type IRGraph struct { // Nodes of the graph. Each node represents a function, keyed by linker // symbol name. IRNodes map[string]*IRNode }
IRNode represents a node (function) in the IRGraph.
type IRNode struct { // Pointer to the IR of the Function represented by this node. AST *ir.Func // Linker symbol name of the Function represented by this node. // Populated only if AST == nil. LinkerSymbolName string // Set of out-edges in the callgraph. The map uniquely identifies each // edge based on the callsite and callee, for fast lookup. OutEdges map[pgo.NamedCallEdge]*IREdge }
func (i *IRNode) Name() string
Name returns the symbol name of this function.
Profile contains the processed PGO profile and weighted call graph used for PGO optimizations.
type Profile struct { // Profile is the base data from the raw profile, without IR attribution. *pgo.Profile // WeightedCG represents the IRGraph built from profile, which we will // update as part of inlining. WeightedCG *IRGraph }
func New(profileFile string) (*Profile, error)
New generates a profile-graph from the profile or pre-processed profile.
func (p *Profile) PrintWeightedCallGraphDOT(edgeThreshold float64)
PrintWeightedCallGraphDOT prints IRGraph in DOT format.