Skip to content

Commit 13bf4ad

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
1 parent d1be0fd commit 13bf4ad

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

src/cmd/compile/internal/gc/inl.go

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -283,33 +283,14 @@ func (v *hairyVisitor) visit(n *Node) bool {
283283
v.budget -= fn.InlCost
284284
break
285285
}
286-
if n.Left.Op == OCLOSURE {
287-
if fn := inlinableClosure(n.Left); fn != nil {
288-
v.budget -= fn.Func.InlCost
289-
break
290-
}
291-
} else if n.Left.Op == ONAME && n.Left.Name != nil && n.Left.Name.Defn != nil {
292-
// NB: this case currently cannot trigger since closure definition
293-
// prevents inlining
294-
// NB: ideally we would also handle captured variables defined as
295-
// closures in the outer scope this brings us back to the idea of
296-
// function value propagation, which if available would both avoid
297-
// the "reassigned" check and neatly handle multiple use cases in a
298-
// single code path
299-
if d := n.Left.Name.Defn; d.Op == OAS && d.Right.Op == OCLOSURE {
300-
if fn := inlinableClosure(d.Right); fn != nil {
301-
v.budget -= fn.Func.InlCost
302-
break
303-
}
304-
}
305-
}
306-
307286
if n.Left.isMethodExpression() {
308287
if d := asNode(n.Left.Sym.Def); d != nil && d.Func.Inl.Len() != 0 {
309288
v.budget -= d.Func.InlCost
310289
break
311290
}
312291
}
292+
// TODO(mdempsky): Budget for OCLOSURE calls if we
293+
// ever allow that. See #15561 and #23093.
313294
if Debug['l'] < 4 {
314295
v.reason = "non-leaf function"
315296
return true

test/fixedbugs/issue23093.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// errorcheck
2+
3+
// Copyright 2017 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
package p
8+
9+
var f = func() { f() } // ERROR "initialization loop"

0 commit comments

Comments
 (0)