]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove broken inlining accounting code
authorMatthew Dempsky <mdempsky@google.com>
Tue, 12 Dec 2017 19:13:49 +0000 (11:13 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Tue, 12 Dec 2017 20:26:33 +0000 (20:26 +0000)
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>
src/cmd/compile/internal/gc/inl.go
test/fixedbugs/issue23093.go [new file with mode: 0644]

index 0e8ef196af758065781d342008c956d0989dc728..c5e1f1390d8f45ba25a581c3639075197651289b 100644 (file)
@@ -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 (file)
index 0000000..2fd7d5f
--- /dev/null
@@ -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"