]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.unified] cmd/compile/internal/noder: remove needType logic
authorMatthew Dempsky <mdempsky@google.com>
Tue, 21 Jun 2022 14:56:25 +0000 (07:56 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 23 Jun 2022 21:54:51 +0000 (21:54 +0000)
This logic is a holdover from very early on when it wasn't as clear
how we would handle dictionary entries for derived types, particularly
ones that are emitted during desugaring.

However, the current plan is to explicitly wire runtime type info
through IR nodes, so we can drop this logic.

Notably, the "needed" bit is exposed to the go/types importers, so
removing it would break the x/tools importer. To minimize churn for
now, we can just leave the bools in place.

Change-Id: I374927887d4f3d6d711d3355607849a407d717c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/413367
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

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

index e2d2aba07227bcd13ce765828e797333474a1768..e773b8973dc68f9e9824268a5700613ae8ccc285 100644 (file)
@@ -179,7 +179,7 @@ type writerDict struct {
 // A derivedInfo represents a reference to an encoded generic Go type.
 type derivedInfo struct {
        idx    pkgbits.Index
-       needed bool
+       needed bool // TODO(mdempsky): Remove; will break x/tools importer
 }
 
 // A typeInfo represents a reference to an encoded Go type.
@@ -1362,13 +1362,6 @@ func (w *writer) expr(expr syntax.Expr) {
        targs := inst.TypeArgs
 
        if tv, ok := w.p.info.Types[expr]; ok {
-               // TODO(mdempsky): Be more judicious about which types are marked as "needed".
-               if inst.Type != nil {
-                       w.needType(inst.Type)
-               } else {
-                       w.needType(tv.Type)
-               }
-
                if tv.IsType() {
                        w.p.fatalf(expr, "unexpected type expression %v", syntax.String(expr))
                }
@@ -1714,20 +1707,6 @@ func (w *writer) op(op ir.Op) {
        w.Len(int(op))
 }
 
-func (w *writer) needType(typ types2.Type) {
-       // Decompose tuple into component element types.
-       if typ, ok := typ.(*types2.Tuple); ok {
-               for i := 0; i < typ.Len(); i++ {
-                       w.needType(typ.At(i).Type())
-               }
-               return
-       }
-
-       if info := w.p.typIdx(typ, w.dict); info.derived {
-               w.dict.derived[info.idx].needed = true
-       }
-}
-
 // @@@ Package initialization
 
 // Caution: This code is still clumsy, because toolstash -cmp is