mirror of
https://github.com/golang/go
synced 2024-11-27 05:21:22 -07:00
cmd/compile/internal/inline: refactor inline budget computation
Split out the code that computes the initial inline "hairyness" budget for a function so that it can be reused (in a later patch). This is a pure refactoring; no change in compiler functionality. Change-Id: I9b1b7b10a7c480559b837492b10eb08771b7a145 Reviewed-on: https://go-review.googlesource.com/c/go/+/514795 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
7087b8ac4c
commit
6eb31c1a00
@ -266,6 +266,26 @@ func garbageCollectUnreferencedHiddenClosures() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// inlineBudget determines the max budget for function 'fn' prior to
|
||||||
|
// analyzing the hairyness of the body of 'fn'. We pass in the pgo
|
||||||
|
// profile if available, which can change the budget. If 'verbose' is
|
||||||
|
// set, then print a remark where we boost the budget due to PGO.
|
||||||
|
func inlineBudget(fn *ir.Func, profile *pgo.Profile, verbose bool) int32 {
|
||||||
|
// Update the budget for profile-guided inlining.
|
||||||
|
budget := int32(inlineMaxBudget)
|
||||||
|
if profile != nil {
|
||||||
|
if n, ok := profile.WeightedCG.IRNodes[ir.LinkFuncName(fn)]; ok {
|
||||||
|
if _, ok := candHotCalleeMap[n]; ok {
|
||||||
|
budget = int32(inlineHotMaxBudget)
|
||||||
|
if verbose {
|
||||||
|
fmt.Printf("hot-node enabled increased budget=%v for func=%v\n", budget, ir.PkgFuncName(fn))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return budget
|
||||||
|
}
|
||||||
|
|
||||||
// CanInline determines whether fn is inlineable.
|
// CanInline determines whether fn is inlineable.
|
||||||
// If so, CanInline saves copies of fn.Body and fn.Dcl in fn.Inl.
|
// If so, CanInline saves copies of fn.Body and fn.Dcl in fn.Inl.
|
||||||
// fn and fn.Body will already have been typechecked.
|
// fn and fn.Body will already have been typechecked.
|
||||||
@ -311,18 +331,8 @@ func CanInline(fn *ir.Func, profile *pgo.Profile) {
|
|||||||
cc = 1 // this appears to yield better performance than 0.
|
cc = 1 // this appears to yield better performance than 0.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the budget for profile-guided inlining.
|
// Compute the inline budget for this function.
|
||||||
budget := int32(inlineMaxBudget)
|
budget := inlineBudget(fn, profile, base.Debug.PGODebug > 0)
|
||||||
if profile != nil {
|
|
||||||
if n, ok := profile.WeightedCG.IRNodes[ir.LinkFuncName(fn)]; ok {
|
|
||||||
if _, ok := candHotCalleeMap[n]; ok {
|
|
||||||
budget = int32(inlineHotMaxBudget)
|
|
||||||
if base.Debug.PGODebug > 0 {
|
|
||||||
fmt.Printf("hot-node enabled increased budget=%v for func=%v\n", budget, ir.PkgFuncName(fn))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// At this point in the game the function we're looking at may
|
// At this point in the game the function we're looking at may
|
||||||
// have "stale" autos, vars that still appear in the Dcl list, but
|
// have "stale" autos, vars that still appear in the Dcl list, but
|
||||||
|
Loading…
Reference in New Issue
Block a user