Commit 13bf4ada authored by Matthew Dempsky's avatar Matthew Dempsky

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: 's avatarRobert Griesemer <gri@golang.org>
parent d1be0fd9
......@@ -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
......
// 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"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment