]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: mark instantiated generic functions as DUPOK
authorMatthew Dempsky <mdempsky@google.com>
Tue, 8 Mar 2022 22:59:32 +0000 (14:59 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 9 Mar 2022 16:08:24 +0000 (16:08 +0000)
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>
src/cmd/compile/internal/noder/reader.go

index 004630236d6880a9491c07a08ddc43359947613e..73e4ddbbedc1229e4bf95e944e0eedbd4406210e 100644 (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.Nname = name
 
+               if r.hasTypeParams() {
+                       name.Func.SetDupok(true)
+               }
+
                rext.funcExt(name)
                return name
 
@@ -790,6 +794,10 @@ func (r *reader) method(rext *reader) *types.Field {
        name.Func = ir.NewFunc(r.pos())
        name.Func.Nname = name
 
+       if r.hasTypeParams() {
+               name.Func.SetDupok(true)
+       }
+
        rext.funcExt(name)
 
        meth := types.NewField(name.Func.Pos(), sym, typ)