const inlineMaxBudget … const inlineExtraAppendCost … const inlineExtraCallCost … const inlineParamCallCost … const inlineExtraPanicCost … const inlineExtraThrowCost … const inlineBigFunctionNodes … const inlineBigFunctionMaxCost … var candHotCalleeMap … var hasHotCall … var candHotEdgeMap … var inlineHotCallSiteThresholdPercent … var inlineCDFHotCallSiteThresholdPercent … var inlineHotMaxBudget … func IsPgoHotFunc(fn *ir.Func, profile *pgoir.Profile) bool { … } func HasPgoHotInline(fn *ir.Func) bool { … } // PGOInlinePrologue records the hot callsites from ir-graph. func PGOInlinePrologue(p *pgoir.Profile) { … } // hotNodesFromCDF computes an edge weight threshold and the list of hot // nodes that make up the given percentage of the CDF. The threshold, as // a percent, is the lower bound of weight for nodes to be considered hot // (currently only used in debug prints) (in case of equal weights, // comparing with the threshold may not accurately reflect which nodes are // considered hot). func hotNodesFromCDF(p *pgoir.Profile) (float64, []pgo.NamedCallEdge) { … } // CanInlineFuncs computes whether a batch of functions are inlinable. func CanInlineFuncs(funcs []*ir.Func, profile *pgoir.Profile) { … } // inlineBudget determines the max budget for function 'fn' prior to // analyzing the hairiness of the body of 'fn'. We pass in the pgo // profile if available (which can change the budget), also a // 'relaxed' flag, which expands the budget slightly to allow for the // possibility that a call to the function might have its score // adjusted downwards. If 'verbose' is set, then print a remark where // we boost the budget due to PGO. func inlineBudget(fn *ir.Func, profile *pgoir.Profile, relaxed bool, verbose bool) int32 { … } // CanInline determines whether fn is inlineable. // If so, CanInline saves copies of fn.Body and fn.Dcl in fn.Inl. // fn and fn.Body will already have been typechecked. func CanInline(fn *ir.Func, profile *pgoir.Profile) { … } // noteInlinableFunc issues a message to the user that the specified // function is inlinable. func noteInlinableFunc(n *ir.Name, fn *ir.Func, cost int32) { … } // InlineImpossible returns a non-empty reason string if fn is impossible to // inline regardless of cost or contents. func InlineImpossible(fn *ir.Func) string { … } // canDelayResults reports whether inlined calls to fn can delay // declaring the result parameter until the "return" statement. func canDelayResults(fn *ir.Func) bool { … } type hairyVisitor … func (v *hairyVisitor) tooHairy(fn *ir.Func) bool { … } // doNode visits n and its children, updates the state in v, and returns true if // n makes the current function too hairy for inlining. func (v *hairyVisitor) doNode(n ir.Node) bool { … } // IsBigFunc reports whether fn is a "big" function. // // Note: The criteria for "big" is heuristic and subject to change. func IsBigFunc(fn *ir.Func) bool { … } // TryInlineCall returns an inlined call expression for call, or nil // if inlining is not possible. func TryInlineCall(callerfn *ir.Func, call *ir.CallExpr, bigCaller bool, profile *pgoir.Profile) *ir.InlinedCallExpr { … } // inlCallee takes a function-typed expression and returns the underlying function ONAME // that it refers to if statically known. Otherwise, it returns nil. func inlCallee(caller *ir.Func, fn ir.Node, profile *pgoir.Profile) (res *ir.Func) { … } var inlgen … var SSADumpInline … var InlineCall … // inlineCostOK returns true if call n from caller to callee is cheap enough to // inline. bigCaller indicates that caller is a big function. // // In addition to the "cost OK" boolean, it also returns // - the "max cost" limit used to make the decision (which may differ depending on func size) // - the score assigned to this specific callsite // - whether the inlined function is "hot" according to PGO. func inlineCostOK(n *ir.CallExpr, caller, callee *ir.Func, bigCaller bool) (bool, int32, int32, bool) { … } // canInlineCallExpr returns true if the call n from caller to callee // can be inlined, plus the score computed for the call expr in question, // and whether the callee is hot according to PGO. // bigCaller indicates that caller is a big function. log // indicates that the 'cannot inline' reason should be logged. // // Preconditions: CanInline(callee) has already been called. func canInlineCallExpr(callerfn *ir.Func, n *ir.CallExpr, callee *ir.Func, bigCaller bool, log bool) (bool, int32, bool) { … } // mkinlcall returns an OINLCALL node that can replace OCALLFUNC n, or // nil if it cannot be inlined. callerfn is the function that contains // n, and fn is the function being called. // // The result of mkinlcall MUST be assigned back to n, e.g. // // n.Left = mkinlcall(n.Left, fn, isddd) func mkinlcall(callerfn *ir.Func, n *ir.CallExpr, fn *ir.Func, bigCaller bool) *ir.InlinedCallExpr { … } // CalleeEffects appends any side effects from evaluating callee to init. func CalleeEffects(init *ir.Nodes, callee ir.Node) { … } func pruneUnusedAutos(ll []*ir.Name, vis *hairyVisitor) []*ir.Name { … } // numNonClosures returns the number of functions in list which are not closures. func numNonClosures(list []*ir.Func) int { … } func doList(list []ir.Node, do func(ir.Node) bool) bool { … } // isIndexingCoverageCounter returns true if the specified node 'n' is indexing // into a coverage counter array. func isIndexingCoverageCounter(n ir.Node) bool { … } // isAtomicCoverageCounterUpdate examines the specified node to // determine whether it represents a call to sync/atomic.AddUint32 to // increment a coverage counter. func isAtomicCoverageCounterUpdate(cn *ir.CallExpr) bool { … } func PostProcessCallSites(profile *pgoir.Profile) { … } func analyzeFuncProps(fn *ir.Func, p *pgoir.Profile) { … }