1
0
mirror of https://github.com/golang/go synced 2024-07-08 12:18:55 +00:00

cmd/compile: disable inlining functions with closures for now

Added a flag '-d=inlfuncswithclosures=1' to allow inlining functions with
closures, and change the default to off for now, until #44370 is fixed.

Updates #44370.

Change-Id: Ic17723aa5c091d91f5f5004d8b63ec7125257acf
Reviewed-on: https://go-review.googlesource.com/c/go/+/296049
Run-TryBot: Dan Scales <danscales@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
This commit is contained in:
Dan Scales 2021-02-24 13:03:17 -08:00
parent 6c3f8a2f47
commit 8027343b63
4 changed files with 31 additions and 30 deletions

View File

@ -40,6 +40,7 @@ type DebugFlags struct {
Export int `help:"print export data"`
Fieldtrack *int `help:"enable field tracking"`
GCProg int `help:"print dump of GC programs"`
InlFuncsWithClosures int `help:"allow functions with closures to be inlined"`
Libfuzzer int `help:"enable coverage instrumentation for libfuzzer"`
LocationLists int `help:"print information about DWARF location list creation"`
Nil int `help:"print information about nil checks"`

View File

@ -354,15 +354,15 @@ func (v *hairyVisitor) doNode(n ir.Node) bool {
return true
case ir.OCLOSURE:
// TODO(danscales,mdempsky): Get working with -G.
// Probably after #43818 is fixed.
if base.Flag.G > 0 {
v.reason = "inlining closures not yet working with -G"
if base.Debug.InlFuncsWithClosures == 0 {
// TODO(danscales): change default of InlFuncsWithClosures
// to 1 when #44370 is fixed
v.reason = "not inlining functions with closures"
return true
}
// TODO(danscales) - fix some bugs when budget is lowered below 15
// Maybe make budget proportional to number of closure variables, e.g.:
// TODO(danscales): Maybe make budget proportional to number of closure
// variables, e.g.:
//v.budget -= int32(len(n.(*ir.ClosureExpr).Func.ClosureVars) * 3)
v.budget -= 15
// Scan body of closure (which DoChildren doesn't automatically

View File

@ -1,4 +1,4 @@
// errorcheckandrundir -0 -m
// errorcheckandrundir -0 -m -d=inlfuncswithclosures=1
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style

View File

@ -1,4 +1,4 @@
// errorcheck -0 -m
// errorcheck -0 -m -d=inlfuncswithclosures=1
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style