]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: disable inlining functions with closures for now
authorDan Scales <danscales@google.com>
Wed, 24 Feb 2021 21:03:17 +0000 (13:03 -0800)
committerDan Scales <danscales@google.com>
Wed, 24 Feb 2021 21:34:21 +0000 (21:34 +0000)
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>

src/cmd/compile/internal/base/debug.go
src/cmd/compile/internal/inline/inl.go
test/closure3.go
test/inline.go

index 164941bb26c434c75a0a986ad423b1be14693382..b9fa3d882e608958e66057788b52fbb779892c94 100644 (file)
@@ -29,28 +29,29 @@ var Debug = DebugFlags{
 // The -d option takes a comma-separated list of settings.
 // Each setting is name=value; for ints, name is short for name=1.
 type DebugFlags struct {
-       Append        int    `help:"print information about append compilation"`
-       Checkptr      int    `help:"instrument unsafe pointer conversions"`
-       Closure       int    `help:"print information about closure compilation"`
-       DclStack      int    `help:"run internal dclstack check"`
-       Defer         int    `help:"print information about defer compilation"`
-       DisableNil    int    `help:"disable nil checks"`
-       DumpPtrs      int    `help:"show Node pointers values in dump output"`
-       DwarfInl      int    `help:"print information about DWARF inlined function creation"`
-       Export        int    `help:"print export data"`
-       Fieldtrack    *int   `help:"enable field tracking"`
-       GCProg        int    `help:"print dump of GC programs"`
-       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"`
-       PCTab         string `help:"print named pc-value table"`
-       Panic         int    `help:"show all compiler panics"`
-       Slice         int    `help:"print information about slice compilation"`
-       SoftFloat     int    `help:"force compiler to emit soft-float code"`
-       TypeAssert    int    `help:"print information about type assertion inlining"`
-       TypecheckInl  int    `help:"eager typechecking of inline function bodies"`
-       WB            int    `help:"print information about write barriers"`
-       ABIWrap       int    `help:"print information about ABI wrapper generation"`
+       Append               int    `help:"print information about append compilation"`
+       Checkptr             int    `help:"instrument unsafe pointer conversions"`
+       Closure              int    `help:"print information about closure compilation"`
+       DclStack             int    `help:"run internal dclstack check"`
+       Defer                int    `help:"print information about defer compilation"`
+       DisableNil           int    `help:"disable nil checks"`
+       DumpPtrs             int    `help:"show Node pointers values in dump output"`
+       DwarfInl             int    `help:"print information about DWARF inlined function creation"`
+       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"`
+       PCTab                string `help:"print named pc-value table"`
+       Panic                int    `help:"show all compiler panics"`
+       Slice                int    `help:"print information about slice compilation"`
+       SoftFloat            int    `help:"force compiler to emit soft-float code"`
+       TypeAssert           int    `help:"print information about type assertion inlining"`
+       TypecheckInl         int    `help:"eager typechecking of inline function bodies"`
+       WB                   int    `help:"print information about write barriers"`
+       ABIWrap              int    `help:"print information about ABI wrapper generation"`
 
        any bool // set when any of the values have been set
 }
index 0e57c1766760056309d93f2b6bb2e5cf2e0664a8..fe6509e4c99d787a387a70e95581f40afd45a7c0 100644 (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
index 37b548d6dcc69c4d3666ea8b16e632becd1c9166..452a52720a9b279b8f5d0b14782509248bc95a1a 100644 (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
index a79f5589fb3a77e4fd42e26199391e2c941adb5a..44c746b2823010b00f11719b0c07d6b58cb36bbf 100644 (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