Skip to content

Commit 7160e32

Browse files
committed
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 <[email protected]> Run-TryBot: Matthew Dempsky <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
1 parent c6d9b38 commit 7160e32

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,10 @@ func (pr *pkgReader) objIdx(idx int, implicits, explicits []*types.Type) ir.Node
644644
name.Func = ir.NewFunc(r.pos())
645645
name.Func.Nname = name
646646

647+
if r.hasTypeParams() {
648+
name.Func.SetDupok(true)
649+
}
650+
647651
rext.funcExt(name)
648652
return name
649653

@@ -790,6 +794,10 @@ func (r *reader) method(rext *reader) *types.Field {
790794
name.Func = ir.NewFunc(r.pos())
791795
name.Func.Nname = name
792796

797+
if r.hasTypeParams() {
798+
name.Func.SetDupok(true)
799+
}
800+
793801
rext.funcExt(name)
794802

795803
meth := types.NewField(name.Func.Pos(), sym, typ)

0 commit comments

Comments
 (0)