1
0
mirror of https://github.com/golang/go synced 2024-11-23 20:30:04 -07:00

cmd/compile: mark instantiated generic functions as DUPOK

Unified IR wasn't marking instantiated generic functions as DUPOK,
even though they can appear in multiple compilation units, which
evidently interfered with cmd/link's dead code elimination logic.

Manually confirmed to fix the issue, but non-trivial to test within
$GOROOT/test currently, because it's only reproducible when
cmd/compile is invoked with -p. @rsc is currently investigating
updating test/run.go appropriately, after which I'll revisit writing a
test case.

Fixes #51519.

Change-Id: I74a79ed0ca15b25b826e419714af5ceb6e567012
Reviewed-on: https://go-review.googlesource.com/c/go/+/390956
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
Matthew Dempsky 2022-03-08 14:59:32 -08:00
parent c6d9b38dd8
commit 7160e32529

View File

@ -644,6 +644,10 @@ func (pr *pkgReader) objIdx(idx int, implicits, explicits []*types.Type) ir.Node
name.Func = ir.NewFunc(r.pos()) name.Func = ir.NewFunc(r.pos())
name.Func.Nname = name name.Func.Nname = name
if r.hasTypeParams() {
name.Func.SetDupok(true)
}
rext.funcExt(name) rext.funcExt(name)
return name return name
@ -790,6 +794,10 @@ func (r *reader) method(rext *reader) *types.Field {
name.Func = ir.NewFunc(r.pos()) name.Func = ir.NewFunc(r.pos())
name.Func.Nname = name name.Func.Nname = name
if r.hasTypeParams() {
name.Func.SetDupok(true)
}
rext.funcExt(name) rext.funcExt(name)
meth := types.NewField(name.Func.Pos(), sym, typ) meth := types.NewField(name.Func.Pos(), sym, typ)