mirror of
https://github.com/golang/go
synced 2024-09-05 07:54:46 +00:00
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 <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
d1be0fd910
commit
13bf4ada80
|
@ -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
|
||||
|
|
9
test/fixedbugs/issue23093.go
Normal file
9
test/fixedbugs/issue23093.go
Normal file
|
@ -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"
|
Loading…
Reference in a new issue