Skip to content

Commit 4f467f1

Browse files
committed
cmd: remove GOEXPERIMENT=nounified knob
This CL removes the GOEXPERIMENT=nounified knob, and any conditional statements that depend on that knob. Further CLs to remove unreachable code follow this one. Updates #57410. Change-Id: I39c147e1a83601c73f8316a001705778fee64a91 Reviewed-on: https://go-review.googlesource.com/c/go/+/458615 Run-TryBot: Matthew Dempsky <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
1 parent 3d49b68 commit 4f467f1

32 files changed

+71
-533
lines changed

src/cmd/compile/internal/base/debug.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ type DebugFlags struct {
4747
SyncFrames int `help:"how many writer stack frames to include at sync points in unified export data"`
4848
TypeAssert int `help:"print information about type assertion inlining"`
4949
TypecheckInl int `help:"eager typechecking of inline function bodies" concurrent:"ok"`
50-
Unified int `help:"enable unified IR construction"`
5150
WB int `help:"print information about write barriers"`
5251
ABIWrap int `help:"print information about ABI wrapper generation"`
5352
MayMoreStack string `help:"call named function before all stack growth checks" concurrent:"ok"`

src/cmd/compile/internal/base/flag.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,6 @@ func ParseFlags() {
167167
Debug.ConcurrentOk = true
168168
Debug.InlFuncsWithClosures = 1
169169
Debug.InlStaticInit = 1
170-
if buildcfg.Experiment.Unified {
171-
Debug.Unified = 1
172-
}
173170
Debug.SyncFrames = -1 // disable sync markers by default
174171

175172
Debug.Checkptr = -1 // so we can tell whether it is set explicitly

src/cmd/compile/internal/devirtualize/devirtualize.go

Lines changed: 42 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -57,58 +57,52 @@ func Call(call *ir.CallExpr) {
5757
return
5858
}
5959

60-
if base.Debug.Unified != 0 {
61-
// N.B., stencil.go converts shape-typed values to interface type
62-
// using OEFACE instead of OCONVIFACE, so devirtualization fails
63-
// above instead. That's why this code is specific to unified IR.
64-
65-
// If typ is a shape type, then it was a type argument originally
66-
// and we'd need an indirect call through the dictionary anyway.
67-
// We're unable to devirtualize this call.
68-
if typ.IsShape() {
69-
return
70-
}
60+
// If typ is a shape type, then it was a type argument originally
61+
// and we'd need an indirect call through the dictionary anyway.
62+
// We're unable to devirtualize this call.
63+
if typ.IsShape() {
64+
return
65+
}
7166

72-
// If typ *has* a shape type, then it's an shaped, instantiated
73-
// type like T[go.shape.int], and its methods (may) have an extra
74-
// dictionary parameter. We could devirtualize this call if we
75-
// could derive an appropriate dictionary argument.
76-
//
77-
// TODO(mdempsky): If typ has has a promoted non-generic method,
78-
// then that method won't require a dictionary argument. We could
79-
// still devirtualize those calls.
80-
//
81-
// TODO(mdempsky): We have the *runtime.itab in recv.TypeWord. It
82-
// should be possible to compute the represented type's runtime
83-
// dictionary from this (e.g., by adding a pointer from T[int]'s
84-
// *runtime._type to .dict.T[int]; or by recognizing static
85-
// references to go:itab.T[int],iface and constructing a direct
86-
// reference to .dict.T[int]).
87-
if typ.HasShape() {
88-
if base.Flag.LowerM != 0 {
89-
base.WarnfAt(call.Pos(), "cannot devirtualize %v: shaped receiver %v", call, typ)
90-
}
91-
return
67+
// If typ *has* a shape type, then it's an shaped, instantiated
68+
// type like T[go.shape.int], and its methods (may) have an extra
69+
// dictionary parameter. We could devirtualize this call if we
70+
// could derive an appropriate dictionary argument.
71+
//
72+
// TODO(mdempsky): If typ has has a promoted non-generic method,
73+
// then that method won't require a dictionary argument. We could
74+
// still devirtualize those calls.
75+
//
76+
// TODO(mdempsky): We have the *runtime.itab in recv.TypeWord. It
77+
// should be possible to compute the represented type's runtime
78+
// dictionary from this (e.g., by adding a pointer from T[int]'s
79+
// *runtime._type to .dict.T[int]; or by recognizing static
80+
// references to go:itab.T[int],iface and constructing a direct
81+
// reference to .dict.T[int]).
82+
if typ.HasShape() {
83+
if base.Flag.LowerM != 0 {
84+
base.WarnfAt(call.Pos(), "cannot devirtualize %v: shaped receiver %v", call, typ)
9285
}
86+
return
87+
}
9388

94-
// Further, if sel.X's type has a shape type, then it's a shaped
95-
// interface type. In this case, the (non-dynamic) TypeAssertExpr
96-
// we construct below would attempt to create an itab
97-
// corresponding to this shaped interface type; but the actual
98-
// itab pointer in the interface value will correspond to the
99-
// original (non-shaped) interface type instead. These are
100-
// functionally equivalent, but they have distinct pointer
101-
// identities, which leads to the type assertion failing.
102-
//
103-
// TODO(mdempsky): We know the type assertion here is safe, so we
104-
// could instead set a flag so that walk skips the itab check. For
105-
// now, punting is easy and safe.
106-
if sel.X.Type().HasShape() {
107-
if base.Flag.LowerM != 0 {
108-
base.WarnfAt(call.Pos(), "cannot devirtualize %v: shaped interface %v", call, sel.X.Type())
109-
}
110-
return
89+
// Further, if sel.X's type has a shape type, then it's a shaped
90+
// interface type. In this case, the (non-dynamic) TypeAssertExpr
91+
// we construct below would attempt to create an itab
92+
// corresponding to this shaped interface type; but the actual
93+
// itab pointer in the interface value will correspond to the
94+
// original (non-shaped) interface type instead. These are
95+
// functionally equivalent, but they have distinct pointer
96+
// identities, which leads to the type assertion failing.
97+
//
98+
// TODO(mdempsky): We know the type assertion here is safe, so we
99+
// could instead set a flag so that walk skips the itab check. For
100+
// now, punting is easy and safe.
101+
if sel.X.Type().HasShape() {
102+
if base.Flag.LowerM != 0 {
103+
base.WarnfAt(call.Pos(), "cannot devirtualize %v: shaped interface %v", call, sel.X.Type())
111104
}
105+
return
112106
}
113107

114108
dt := ir.NewTypeAssertExpr(sel.Pos(), sel.X, nil)

src/cmd/compile/internal/importer/gcimporter_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"cmd/compile/internal/types2"
1010
"fmt"
1111
"go/build"
12-
"internal/goexperiment"
1312
"internal/testenv"
1413
"os"
1514
"os/exec"
@@ -98,7 +97,7 @@ func TestImportTestdata(t *testing.T) {
9897
"exports.go": {"go/ast", "go/token"},
9998
"generics.go": nil,
10099
}
101-
if goexperiment.Unified {
100+
if true /* was goexperiment.Unified */ {
102101
// TODO(mdempsky): Fix test below to flatten the transitive
103102
// Package.Imports graph. Unified IR is more precise about
104103
// recreating the package import graph.
@@ -343,8 +342,12 @@ func verifyInterfaceMethodRecvs(t *testing.T, named *types2.Named, level int) {
343342
// The unified IR importer always sets interface method receiver
344343
// parameters to point to the Interface type, rather than the Named.
345344
// See #49906.
345+
//
346+
// TODO(mdempsky): This is only true for the types2 importer. For
347+
// the go/types importer, we duplicate the Interface and rewrite its
348+
// receiver methods to match historical behavior.
346349
var want types2.Type = named
347-
if goexperiment.Unified {
350+
if true /* was goexperiment.Unified */ {
348351
want = iface
349352
}
350353

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

Lines changed: 7 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -645,15 +645,13 @@ func (v *hairyVisitor) doNode(n ir.Node) bool {
645645
// minimize impact to the existing inlining heuristics (in
646646
// particular, to avoid breaking the existing inlinability regress
647647
// tests), we need to compensate for this here.
648-
if base.Debug.Unified != 0 {
649-
if init := n.Rhs[0].Init(); len(init) == 1 {
650-
if _, ok := init[0].(*ir.AssignListStmt); ok {
651-
// 4 for each value, because each temporary variable now
652-
// appears 3 times (DCL, LHS, RHS), plus an extra DCL node.
653-
//
654-
// 1 for the extra "tmp1, tmp2 = f()" assignment statement.
655-
v.budget += 4*int32(len(n.Lhs)) + 1
656-
}
648+
if init := n.Rhs[0].Init(); len(init) == 1 {
649+
if _, ok := init[0].(*ir.AssignListStmt); ok {
650+
// 4 for each value, because each temporary variable now
651+
// appears 3 times (DCL, LHS, RHS), plus an extra DCL node.
652+
//
653+
// 1 for the extra "tmp1, tmp2 = f()" assignment statement.
654+
v.budget += 4*int32(len(n.Lhs)) + 1
657655
}
658656
}
659657

@@ -958,49 +956,6 @@ func mkinlcall(n *ir.CallExpr, fn *ir.Func, maxCost int32, inlCalls *[]*ir.Inlin
958956
return n
959957
}
960958

961-
// The non-unified frontend has issues with inlining and shape parameters.
962-
if base.Debug.Unified == 0 {
963-
// Don't inline a function fn that has no shape parameters, but is passed at
964-
// least one shape arg. This means we must be inlining a non-generic function
965-
// fn that was passed into a generic function, and can be called with a shape
966-
// arg because it matches an appropriate type parameters. But fn may include
967-
// an interface conversion (that may be applied to a shape arg) that was not
968-
// apparent when we first created the instantiation of the generic function.
969-
// We can't handle this if we actually do the inlining, since we want to know
970-
// all interface conversions immediately after stenciling. So, we avoid
971-
// inlining in this case, see issue #49309. (1)
972-
//
973-
// See discussion on go.dev/cl/406475 for more background.
974-
if !fn.Type().Params().HasShape() {
975-
for _, arg := range n.Args {
976-
if arg.Type().HasShape() {
977-
if logopt.Enabled() {
978-
logopt.LogOpt(n.Pos(), "cannotInlineCall", "inline", ir.FuncName(ir.CurFunc),
979-
fmt.Sprintf("inlining function %v has no-shape params with shape args", ir.FuncName(fn)))
980-
}
981-
return n
982-
}
983-
}
984-
} else {
985-
// Don't inline a function fn that has shape parameters, but is passed no shape arg.
986-
// See comments (1) above, and issue #51909.
987-
inlineable := len(n.Args) == 0 // Function has shape in type, with no arguments can always be inlined.
988-
for _, arg := range n.Args {
989-
if arg.Type().HasShape() {
990-
inlineable = true
991-
break
992-
}
993-
}
994-
if !inlineable {
995-
if logopt.Enabled() {
996-
logopt.LogOpt(n.Pos(), "cannotInlineCall", "inline", ir.FuncName(ir.CurFunc),
997-
fmt.Sprintf("inlining function %v has shape params with no-shape args", ir.FuncName(fn)))
998-
}
999-
return n
1000-
}
1001-
}
1002-
}
1003-
1004959
if base.Flag.Cfg.Instrumenting && types.IsRuntimePkg(fn.Sym().Pkg) {
1005960
// Runtime package must not be instrumented.
1006961
// Instrument skips runtime package. However, some runtime code can be

src/cmd/compile/internal/noder/export.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,14 @@ import (
1010
"io"
1111

1212
"cmd/compile/internal/base"
13-
"cmd/compile/internal/typecheck"
1413
"cmd/internal/bio"
1514
)
1615

1716
func WriteExports(out *bio.Writer) {
1817
var data bytes.Buffer
1918

20-
if base.Debug.Unified != 0 {
21-
data.WriteByte('u')
22-
writeUnifiedExport(&data)
23-
} else {
24-
typecheck.WriteExports(&data, true)
25-
}
19+
data.WriteByte('u')
20+
writeUnifiedExport(&data)
2621

2722
// The linker also looks for the $$ marker - use char after $$ to distinguish format.
2823
out.WriteString("\n$$B\n") // indicate binary export format

src/cmd/compile/internal/noder/import.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,6 @@ func readImportFile(path string, target *ir.Package, env *types2.Context, packag
231231

232232
switch c {
233233
case 'u':
234-
if !buildcfg.Experiment.Unified {
235-
base.Fatalf("unexpected export data format")
236-
}
237-
238234
// TODO(mdempsky): This seems a bit clunky.
239235
data = strings.TrimSuffix(data, "\n$$\n")
240236

@@ -244,20 +240,6 @@ func readImportFile(path string, target *ir.Package, env *types2.Context, packag
244240
readPackage(newPkgReader(pr), pkg1, false)
245241
pkg2 = importer.ReadPackage(env, packages, pr)
246242

247-
case 'i':
248-
if buildcfg.Experiment.Unified {
249-
base.Fatalf("unexpected export data format")
250-
}
251-
252-
typecheck.ReadImports(pkg1, data)
253-
254-
if packages != nil {
255-
pkg2, err = importer.ImportData(packages, data, path)
256-
if err != nil {
257-
return
258-
}
259-
}
260-
261243
default:
262244
// Indexed format is distinguished by an 'i' byte,
263245
// whereas previous export formats started with 'c', 'd', or 'v'.

src/cmd/compile/internal/noder/noder.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,7 @@ func LoadPackage(filenames []string) {
7373
}
7474
base.Timer.AddEvent(int64(lines), "lines")
7575

76-
if base.Debug.Unified != 0 {
77-
unified(noders)
78-
return
79-
}
80-
81-
// Use types2 to type-check and generate IR.
82-
check2(noders)
76+
unified(noders)
8377
}
8478

8579
func (p *noder) errorAt(pos syntax.Pos, format string, args ...interface{}) {

src/cmd/compile/internal/noder/reader.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3688,11 +3688,6 @@ func (r *reader) importedDef() bool {
36883688
}
36893689

36903690
func MakeWrappers(target *ir.Package) {
3691-
// Only unified IR emits its own wrappers.
3692-
if base.Debug.Unified == 0 {
3693-
return
3694-
}
3695-
36963691
// always generate a wrapper for error.Error (#29304)
36973692
needWrapperTypes = append(needWrapperTypes, types.ErrorType)
36983693

src/cmd/compile/internal/reflectdata/helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func hasRType(n, rtype ir.Node, fieldName string) bool {
2121
// gets confused by implicit conversions. Also, because
2222
// package-scope statements can never be generic, so they'll never
2323
// require dictionary lookups.
24-
if base.Debug.Unified != 0 && ir.CurFunc.Nname.Sym().Name != "init" {
24+
if ir.CurFunc.Nname.Sym().Name != "init" {
2525
ir.Dump("CurFunc", ir.CurFunc)
2626
base.FatalfAt(n.Pos(), "missing %s in %v: %+v", fieldName, ir.CurFunc, n)
2727
}

0 commit comments

Comments
 (0)