// computing flags/properties for the return values of a specific Go
// function, as part of inline heuristics synthesis.
type returnsAnalyzer struct {
- fname string
- props []ResultPropBits
- values []resultVal
- canInline func(*ir.Func)
+ fname string
+ props []ResultPropBits
+ values []resultVal
+ canInline func(*ir.Func)
+ inlineMaxBudget int32
}
// resultVal captures information about a specific result returned from
derived bool // see deriveReturnFlagsFromCallee below
}
-func makeResultsAnalyzer(fn *ir.Func, canInline func(*ir.Func)) *returnsAnalyzer {
+func makeResultsAnalyzer(fn *ir.Func, canInline func(*ir.Func), inlineMaxBudget int32) *returnsAnalyzer {
results := fn.Type().Results()
props := make([]ResultPropBits, len(results))
vals := make([]resultVal, len(results))
vals[i].top = true
}
return &returnsAnalyzer{
- props: props,
- values: vals,
- canInline: canInline,
+ props: props,
+ values: vals,
+ canInline: canInline,
+ inlineMaxBudget: inlineMaxBudget,
}
}
ra.canInline(f)
}
}
- if f.Inl != nil {
+ // HACK: in order to allow for call site score
+ // adjustments, we used a relaxed inline budget in
+ // determining inlinability. Here what we want to know is
+ // whether the func in question is likely to be inlined,
+ // as opposed to whether it might possibly be inlined if
+ // all the right score adjustments happened, so check the
+ // cost here as well.
+ if f.Inl != nil && f.Inl.Cost <= ra.inlineMaxBudget {
ra.props[i] = ResultAlwaysSameInlinableFunc
}
}