type IRGraph … type IRNode … // Name returns the symbol name of this function. func (i *IRNode) Name() string { … } type IREdge … type CallSiteInfo … type Profile … // New generates a profile-graph from the profile or pre-processed profile. func New(profileFile string) (*Profile, error) { … } // initializeIRGraph builds the IRGraph by visiting all the ir.Func in decl list // of a package. func createIRGraph(namedEdgeMap pgo.NamedEdgeMap) *IRGraph { … } // visitIR traverses the body of each ir.Func adds edges to g from ir.Func to // any called function in the body. func visitIR(fn *ir.Func, namedEdgeMap pgo.NamedEdgeMap, g *IRGraph) { … } // createIRGraphEdge traverses the nodes in the body of ir.Func and adds edges // between the callernode which points to the ir.Func and the nodes in the // body. func createIRGraphEdge(fn *ir.Func, callernode *IRNode, name string, namedEdgeMap pgo.NamedEdgeMap, g *IRGraph) { … } // NodeLineOffset returns the line offset of n in fn. func NodeLineOffset(n ir.Node, fn *ir.Func) int { … } // addIREdge adds an edge between caller and new node that points to `callee` // based on the profile-graph and NodeMap. func addIREdge(callerNode *IRNode, callerName string, call ir.Node, callee *ir.Func, namedEdgeMap pgo.NamedEdgeMap, g *IRGraph) { … } var LookupFunc … var PostLookupCleanup … // addIndirectEdges adds indirect call edges found in the profile to the graph, // to be used for devirtualization. // // N.B. despite the name, addIndirectEdges will add any edges discovered via // the profile. We don't know for sure that they are indirect, but assume they // are since direct calls would already be added. (e.g., direct calls that have // been deleted from source since the profile was taken would be added here). // // TODO(prattmic): Devirtualization runs before inlining, so we can't devirtualize // calls inside inlined call bodies. If we did add that, we'd need edges from // inlined bodies as well. func addIndirectEdges(g *IRGraph, namedEdgeMap pgo.NamedEdgeMap) { … } // PrintWeightedCallGraphDOT prints IRGraph in DOT format. func (p *Profile) PrintWeightedCallGraphDOT(edgeThreshold float64) { … } // 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 DirectCallee(fn ir.Node) *ir.Func { … }