if base.Debug.DumpInlFuncProps != "" {
inlheur.DumpFuncProps(nil, base.Debug.DumpInlFuncProps, nil, inlineMaxBudget)
}
- if goexperiment.NewInliner {
+ if useNewInliner() {
postProcessCallSites(p)
}
}
}
var funcProps *inlheur.FuncProps
- if goexperiment.NewInliner || inlheur.UnitTesting() {
+ if useNewInliner() {
callCanInline := func(fn *ir.Func) { CanInline(fn, profile) }
funcProps = inlheur.AnalyzeFunc(fn, callCanInline, inlineMaxBudget)
+ budgetForFunc := func(fn *ir.Func) int32 {
+ return inlineBudget(fn, profile, true, false)
+ }
+ defer func() { inlheur.RevisitInlinability(fn, budgetForFunc) }()
}
var reason string // reason, if any, that the function was not inlined
cc = 1 // this appears to yield better performance than 0.
}
- // Used a "relaxed" inline budget if goexperiment.NewInliner is in
- // effect, or if we're producing a debugging dump.
- relaxed := goexperiment.NewInliner ||
- (base.Debug.DumpInlFuncProps != "" ||
- base.Debug.DumpInlCallSiteScores != 0)
+ // Used a "relaxed" inline budget if the new inliner is enabled.
+ relaxed := useNewInliner()
// Compute the inline budget for this func.
budget := inlineBudget(fn, profile, relaxed, base.Debug.PGODebug > 0)
CanDelayResults: canDelayResults(fn),
}
- if goexperiment.NewInliner {
+ if useNewInliner() {
n.Func.Inl.Properties = funcProps.SerializeToString()
}
// InlineCalls/inlnode walks fn's statements and expressions and substitutes any
// calls made to inlineable functions. This is the external entry point.
func InlineCalls(fn *ir.Func, profile *pgo.Profile) {
- if goexperiment.NewInliner && !fn.Wrapper() {
+ if useNewInliner() && !fn.Wrapper() {
inlheur.ScoreCalls(fn)
+ defer inlheur.ScoreCallsCleanup()
}
if base.Debug.DumpInlFuncProps != "" && !fn.Wrapper() {
inlheur.DumpFuncProps(fn, base.Debug.DumpInlFuncProps,
}
metric := callee.Inl.Cost
- if goexperiment.NewInliner {
- ok, score := inlheur.GetCallSiteScore(n)
+ if useNewInliner() {
+ score, ok := inlheur.GetCallSiteScore(caller, n)
if ok {
metric = int32(score)
}
return v
}
+func useNewInliner() bool {
+ return goexperiment.NewInliner ||
+ inlheur.UnitTesting()
+}
+
func postProcessCallSites(profile *pgo.Profile) {
if base.Debug.DumpInlCallSiteScores != 0 {
budgetCallback := func(fn *ir.Func, prof *pgo.Profile) (int32, bool) {