From f5371581c73f2153bb7e7c85648896ff8bdce845 Mon Sep 17 00:00:00 2001 From: Than McIntosh Date: Mon, 3 Apr 2023 14:25:58 +0000 Subject: Revert "cmd/compile: allow more inlining of functions that construct closures" This reverts commit http://go.dev/cl//479095 Reason for revert: causes failures in google-internal testing Change-Id: If1018b35be0b8627e2959f116179ada24d44d67c Reviewed-on: https://go-review.googlesource.com/c/go/+/481637 TryBot-Result: Gopher Robot Reviewed-by: Michael Pratt Run-TryBot: Than McIntosh --- src/cmd/compile/internal/inline/inl.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/cmd/compile/internal/inline/inl.go b/src/cmd/compile/internal/inline/inl.go index b8f3f9baee..80be841efa 100644 --- a/src/cmd/compile/internal/inline/inl.go +++ b/src/cmd/compile/internal/inline/inl.go @@ -446,8 +446,6 @@ func (v *hairyVisitor) tooHairy(fn *ir.Func) bool { return false } -// doNode visits n and its children, updates the state in v, and returns true if -// n makes the current function too hairy for inlining. func (v *hairyVisitor) doNode(n ir.Node) bool { if n == nil { return false @@ -579,10 +577,13 @@ func (v *hairyVisitor) doNode(n ir.Node) bool { // TODO(danscales): Maybe make budget proportional to number of closure // variables, e.g.: //v.budget -= int32(len(n.(*ir.ClosureExpr).Func.ClosureVars) * 3) - // TODO(austin): However, if we're able to inline this closure into - // v.curFunc, then we actually pay nothing for the closure captures. We - // should try to account for that if we're going to account for captures. v.budget -= 15 + // Scan body of closure (which DoChildren doesn't automatically + // do) to check for disallowed ops in the body and include the + // body in the budget. + if doList(n.(*ir.ClosureExpr).Func.Body, v.do) { + return true + } case ir.OGO, ir.ODEFER, -- cgit v1.3