From 0ae0d5c62eae1a4043d1d9cb41acc563a5e75daa Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Thu, 21 Oct 2021 19:15:24 -0700 Subject: [PATCH] cmd/compile: remove MarkUsedIfaceMethodIndex mechanism 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 Trust: Dan Scales Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Dan Scales --- src/cmd/compile/internal/noder/stencil.go | 28 ++++--------------- .../compile/internal/reflectdata/reflect.go | 10 ------- 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index 474a05973a..fc5b0eefd4 100644 --- a/src/cmd/compile/internal/noder/stencil.go +++ b/src/cmd/compile/internal/noder/stencil.go @@ -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()) diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index 369ee75422..b4ed96c18a 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -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 { -- 2.50.0