]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove MarkUsedIfaceMethodIndex mechanism
authorKeith Randall <khr@golang.org>
Fri, 22 Oct 2021 02:15:24 +0000 (19:15 -0700)
committerKeith Randall <khr@golang.org>
Mon, 25 Oct 2021 20:39:31 +0000 (20:39 +0000)
We don't need it any more, after CL 357835.

Change-Id: I1ff5f24b5540c3e80c4b35be8215a1c378952274
Reviewed-on: https://go-review.googlesource.com/c/go/+/357894
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
src/cmd/compile/internal/noder/stencil.go
src/cmd/compile/internal/reflectdata/reflect.go

index 474a05973aa09941ce48a1a3026e40c9b6e67e3f..fc5b0eefd4c8a44f804f07b4f0a21e1f1859011f 100644 (file)
@@ -1523,18 +1523,12 @@ func deref(t *types.Type) *types.Type {
 // needed methods.
 func markTypeUsed(t *types.Type, lsym *obj.LSym) {
        if t.IsInterface() {
-               // Mark all the methods of the interface as used.
-               // TODO: we should really only mark the interface methods
-               // that are actually called in the application.
-               for i, _ := range t.AllMethods().Slice() {
-                       reflectdata.MarkUsedIfaceMethodIndex(lsym, t, i)
-               }
-       } else {
-               // TODO: This is somewhat overkill, we really only need it
-               // for types that are put into interfaces.
-               // Note: this relocation is also used in cmd/link/internal/ld/dwarf.go
-               reflectdata.MarkTypeUsedInInterface(t, lsym)
+               return
        }
+       // TODO: This is somewhat overkill, we really only need it
+       // for types that are put into interfaces.
+       // Note: this relocation is also used in cmd/link/internal/ld/dwarf.go
+       reflectdata.MarkTypeUsedInInterface(t, lsym)
 }
 
 // getDictionarySym returns the dictionary for the named generic function gf, which
@@ -1735,18 +1729,6 @@ func (g *genInst) finalizeSyms() {
                                se := n.(*ir.SelectorExpr)
                                srctype = subst.Typ(se.X.Type())
                                dsttype = subst.Typ(info.shapeToBound[se.X.Type()])
-                               found := false
-                               for i, m := range dsttype.AllMethods().Slice() {
-                                       if se.Sel == m.Sym {
-                                               // Mark that this method se.Sel is
-                                               // used for the dsttype interface, so
-                                               // it won't get deadcoded.
-                                               reflectdata.MarkUsedIfaceMethodIndex(lsym, dsttype, i)
-                                               found = true
-                                               break
-                                       }
-                               }
-                               assert(found)
                        case ir.ODOTTYPE, ir.ODOTTYPE2:
                                srctype = subst.Typ(n.(*ir.TypeAssertExpr).Type())
                                dsttype = subst.Typ(n.(*ir.TypeAssertExpr).X.Type())
index 369ee7542247953ac9e5a477aadd24468d1faf68..b4ed96c18a103944ff49a42fefe1323cd52a6c35 100644 (file)
@@ -2033,16 +2033,6 @@ func MarkUsedIfaceMethod(n *ir.CallExpr) {
        r.Type = objabi.R_USEIFACEMETHOD
 }
 
-// MarkUsedIfaceMethodIndex marks that that method number ix (in the AllMethods list)
-// of interface type ityp is used, and should be attached to lsym.
-func MarkUsedIfaceMethodIndex(lsym *obj.LSym, ityp *types.Type, ix int) {
-       tsym := TypeLinksym(ityp)
-       r := obj.Addrel(lsym)
-       r.Sym = tsym
-       r.Add = InterfaceMethodOffset(ityp, int64(ix))
-       r.Type = objabi.R_USEIFACEMETHOD
-}
-
 // getDictionary returns the dictionary for the given named generic function
 // or method, with the given type arguments.
 func getDictionary(gf *types.Sym, targs []*types.Type) ir.Node {