]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/compile: flag 'large' functions when -m=2+ in effect
authorThan McIntosh <thanm@google.com>
Tue, 3 Jan 2023 18:11:10 +0000 (13:11 -0500)
committerThan McIntosh <thanm@google.com>
Tue, 24 Jan 2023 13:28:54 +0000 (13:28 +0000)
When -m=N (where N > 1) is in effect, include a note in the trace
output if a given function is considered "big" during inlining
analysis, since this causes the inliner to be less aggressive. If a
small change to a large function happens to nudge it over the large
function threshold, it can be confusing for developers, thus it's
probably worth including this info in the remark output.

Change-Id: Id31a1b76371ab1ef9265ba28a377f97b0247d0a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/460317
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Keith Randall <khr@google.com>
src/cmd/compile/internal/inline/inl.go
test/inline_big.go

index 8620db2adb1e974fada7dea0fac280f10ac1e067..e3b2e44f61ab351e83773063708fb410a021d50a 100644 (file)
@@ -742,6 +742,9 @@ func InlineCalls(fn *ir.Func, profile *pgo.Profile) {
        ir.CurFunc = fn
        maxCost := int32(inlineMaxBudget)
        if isBigFunc(fn) {
+               if base.Flag.LowerM > 1 {
+                       fmt.Printf("%v: function %v considered 'big'; revising maxCost from %d to %d\n", ir.Line(fn), fn, maxCost, inlineBigFunctionMaxCost)
+               }
                maxCost = inlineBigFunctionMaxCost
        }
        var inlCalls []*ir.InlinedCallExpr
index 83672753f78a171bd224fa71705eb3e7dc4c2118..7dd1abdb6ae18b53a74659c66cf38318c13cd243 100644 (file)
@@ -20,7 +20,7 @@ func medium(a []int) int { // ERROR "can inline medium with cost .* as:.*" "a do
        return a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7]
 }
 
-func f(a []int) int { // ERROR "cannot inline f:.*" "a does not escape"
+func f(a []int) int { // ERROR "cannot inline f:.*" "a does not escape" "function f considered 'big'"
        // Add lots of nodes to f's body. We need >5000.
        // See cmd/compile/internal/gc/inl.go:inlineBigFunction*
        a[0] = 0