]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: add a debug flag to enable/disable open-coded defers
authorCherry Zhang <cherryyz@google.com>
Sat, 3 Apr 2021 01:48:00 +0000 (21:48 -0400)
committerCherry Zhang <cherryyz@google.com>
Mon, 5 Apr 2021 17:22:26 +0000 (17:22 +0000)
For debugging.

Change-Id: I831947376569cd2285b713ad304329951adf60ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/307230
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Austin Clements <austin@google.com>
src/cmd/compile/internal/base/debug.go
src/cmd/compile/internal/ssagen/ssa.go

index 7590dc1bfa9561c212af66190f26562e5d3c80c9..71712ab1a56fd281f52d3befede9b833caa70fbd 100644 (file)
@@ -39,6 +39,7 @@ type DebugFlags struct {
        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"`
+       NoOpenDefer          int    `help:"disable open-coded defers"`
        PCTab                string `help:"print named pc-value table"`
        Panic                int    `help:"show all compiler panics"`
        Slice                int    `help:"print information about slice compilation"`
index 67c9e9c19858a2758db601b6b1c95d1ff7e58b3e..0a49ca214dca3066dc90a5ce3e18c385bac12ff2 100644 (file)
@@ -470,6 +470,8 @@ func buildssa(fn *ir.Func, worker int) *ssa.Func {
 
        s.hasOpenDefers = base.Flag.N == 0 && s.hasdefer && !s.curfn.OpenCodedDeferDisallowed()
        switch {
+       case base.Debug.NoOpenDefer != 0:
+               s.hasOpenDefers = false
        case s.hasOpenDefers && (base.Ctxt.Flag_shared || base.Ctxt.Flag_dynlink) && base.Ctxt.Arch.Name == "386":
                // Don't support open-coded defers for 386 ONLY when using shared
                // libraries, because there is extra code (added by rewriteToUseGot())