From 859d903b06af669edbbc74be371186f732b60bfa Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Mon, 21 Jun 2021 20:03:58 -0700 Subject: [PATCH] [dev.typeparams] cmd/compile: add -d=unifiedquirks for quirks mode Originally, overloading -d=inlfuncswithclosures=0 to enable quirks mode was convenient because toolstash -cmp doesn't provide a way to pass different gcflags to the installed vs stashed toolchains. Prior to unified IR being merged, the stashed toolchain wouldn't know about or accept any unified-specific flags. However, this concern is no longer applicable since unified IR has been merged, and the TestUnifiedCompare test can easily specify different flag sets for the baseline and experiment build configs. This CL adds a new -d=unifiedquirks flag to enable quirks mode, so that it's possible to test unified IR with -d=inlfuncswithclosures=0 without also affecting a bunch of other compilation details. Change-Id: Id1932f332822622aa8617278e82ec6d1a53b1b46 Reviewed-on: https://go-review.googlesource.com/c/go/+/329733 Trust: Matthew Dempsky Reviewed-by: Cuong Manh Le Run-TryBot: Matthew Dempsky TryBot-Result: Go Bot --- src/cmd/compile/internal/base/debug.go | 1 + src/cmd/compile/internal/noder/quirks.go | 5 +---- src/cmd/compile/internal/noder/unified_test.go | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/cmd/compile/internal/base/debug.go b/src/cmd/compile/internal/base/debug.go index fd42021946..e2245e1c26 100644 --- a/src/cmd/compile/internal/base/debug.go +++ b/src/cmd/compile/internal/base/debug.go @@ -48,6 +48,7 @@ type DebugFlags struct { TypeAssert int `help:"print information about type assertion inlining"` TypecheckInl int `help:"eager typechecking of inline function bodies"` Unified int `help:"enable unified IR construction"` + UnifiedQuirks int `help:"enable unified IR construction's quirks mode"` WB int `help:"print information about write barriers"` ABIWrap int `help:"print information about ABI wrapper generation"` diff --git a/src/cmd/compile/internal/noder/quirks.go b/src/cmd/compile/internal/noder/quirks.go index 28a729f276..91b4c22025 100644 --- a/src/cmd/compile/internal/noder/quirks.go +++ b/src/cmd/compile/internal/noder/quirks.go @@ -23,10 +23,7 @@ import ( // quirksMode controls whether behavior specific to satisfying // toolstash -cmp is used. func quirksMode() bool { - // Currently, unified IR doesn't try to be compatible with - // -d=inlfuncswithclosures=1, so we overload this as a flag for - // enabling quirks mode. - return base.Debug.InlFuncsWithClosures == 0 + return base.Debug.UnifiedQuirks != 0 } // posBasesOf returns all of the position bases in the source files, diff --git a/src/cmd/compile/internal/noder/unified_test.go b/src/cmd/compile/internal/noder/unified_test.go index 242fa1282f..4732892f6c 100644 --- a/src/cmd/compile/internal/noder/unified_test.go +++ b/src/cmd/compile/internal/noder/unified_test.go @@ -59,7 +59,7 @@ func TestUnifiedCompare(t *testing.T) { } pkgs1 := loadPackages(t, goos, goarch, "-d=unified=0 -d=inlfuncswithclosures=0") - pkgs2 := loadPackages(t, goos, goarch, "-d=unified=1 -d=inlfuncswithclosures=0") + pkgs2 := loadPackages(t, goos, goarch, "-d=unified=1 -d=inlfuncswithclosures=0 -d=unifiedquirks=1") if len(pkgs1) != len(pkgs2) { t.Fatalf("length mismatch: %v != %v", len(pkgs1), len(pkgs2)) -- 2.50.0