]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/cmd/compile/internal/inline/inlheur/analyze.go
cmd/compile/inline/inleur: use "largest possible score" to revise inlinability
[gostls13.git] / src / cmd / compile / internal / inline / inlheur / analyze.go
index 9af7e1207d9f1b8a3089529d61b194b869ad247b..3ef750bf615fd62b2bbc763485e9df2cef63dbdb 100644 (file)
@@ -83,6 +83,28 @@ func AnalyzeFunc(fn *ir.Func, canInline func(*ir.Func), inlineMaxBudget int32) *
        return funcProps
 }
 
+// RevisitInlinability revisits the question of whether to continue to
+// treat function 'fn' as an inline candidate based on the set of
+// properties we've computed for it. If (for example) it has an
+// initial size score of 150 and no interesting properties to speak
+// of, then there isn't really any point to moving ahead with it as an
+// inline candidate.
+func RevisitInlinability(fn *ir.Func, budgetForFunc func(*ir.Func) int32) {
+       if fn.Inl == nil {
+               return
+       }
+       entry, ok := fpmap[fn]
+       if !ok {
+               //FIXME: issue error?
+               return
+       }
+       mxAdjust := int32(largestScoreAdjustment(fn, entry.props))
+       budget := budgetForFunc(fn)
+       if fn.Inl.Cost+mxAdjust > budget {
+               fn.Inl = nil
+       }
+}
+
 // computeFuncProps examines the Go function 'fn' and computes for it
 // a function "properties" object, to be used to drive inlining
 // heuristics. See comments on the FuncProps type for more info.