From 13bf4ada8075d9365c40b03ecf6641473b2af926 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Tue, 12 Dec 2017 11:13:49 -0800 Subject: [PATCH] cmd/compile: remove broken inlining accounting code We can't currently inline functions that contain closures anyway, so just delete this budgeting code for now. Re-enable once we can (if ever) inline functions with nested closures. Updates #15561. Fixes #23093. Change-Id: Idc5f8e042ccfcc8921022e58d3843719d4ab821e Reviewed-on: https://go-review.googlesource.com/83538 Run-TryBot: Matthew Dempsky TryBot-Result: Gobot Gobot Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/gc/inl.go | 23 ++--------------------- test/fixedbugs/issue23093.go | 9 +++++++++ 2 files changed, 11 insertions(+), 21 deletions(-) create mode 100644 test/fixedbugs/issue23093.go diff --git a/src/cmd/compile/internal/gc/inl.go b/src/cmd/compile/internal/gc/inl.go index 0e8ef196af..c5e1f1390d 100644 --- a/src/cmd/compile/internal/gc/inl.go +++ b/src/cmd/compile/internal/gc/inl.go @@ -283,33 +283,14 @@ func (v *hairyVisitor) visit(n *Node) bool { v.budget -= fn.InlCost break } - if n.Left.Op == OCLOSURE { - if fn := inlinableClosure(n.Left); fn != nil { - v.budget -= fn.Func.InlCost - break - } - } else if n.Left.Op == ONAME && n.Left.Name != nil && n.Left.Name.Defn != nil { - // NB: this case currently cannot trigger since closure definition - // prevents inlining - // NB: ideally we would also handle captured variables defined as - // closures in the outer scope this brings us back to the idea of - // function value propagation, which if available would both avoid - // the "reassigned" check and neatly handle multiple use cases in a - // single code path - if d := n.Left.Name.Defn; d.Op == OAS && d.Right.Op == OCLOSURE { - if fn := inlinableClosure(d.Right); fn != nil { - v.budget -= fn.Func.InlCost - break - } - } - } - if n.Left.isMethodExpression() { if d := asNode(n.Left.Sym.Def); d != nil && d.Func.Inl.Len() != 0 { v.budget -= d.Func.InlCost break } } + // TODO(mdempsky): Budget for OCLOSURE calls if we + // ever allow that. See #15561 and #23093. if Debug['l'] < 4 { v.reason = "non-leaf function" return true diff --git a/test/fixedbugs/issue23093.go b/test/fixedbugs/issue23093.go new file mode 100644 index 0000000000..2fd7d5fff1 --- /dev/null +++ b/test/fixedbugs/issue23093.go @@ -0,0 +1,9 @@ +// errorcheck + +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +var f = func() { f() } // ERROR "initialization loop"