]> Cypherpunks repositories - gostls13.git/commit
[dev.typeparams] cmd/compile: ensure methods of generic types survive linker pruning
authorKeith Randall <khr@golang.org>
Tue, 20 Jul 2021 19:55:51 +0000 (12:55 -0700)
committerKeith Randall <khr@golang.org>
Wed, 21 Jul 2021 21:05:28 +0000 (21:05 +0000)
commit2fe4b14795fe20fa3ba8efbe92b88f2d564509d2
treeb0899372ca8f1ff6ec2a634156770a5eb269c894
parent73af5f718f6012c0a76cabd43c91505d5a80c169
[dev.typeparams] cmd/compile: ensure methods of generic types survive linker pruning

Calling MarkTypeUsedInInterface before inlining is problematic (when
using the containing function as the reference source), because we end
up attaching a relocation to the original function, which is then
deadcode removed because all instances of it were inlined. (All other
current uses of MarkTypeUsedInInterface happen after inlining, so they
don't have this problem.)

Instead, attach the relocation to the dictionary in which the type
appears.  This should always work, because if the dictionary is ever
deadcode eliminated, then the type can never be put in an interface,
which means we indeed don't need its methods.

This CL is a bit overkill, as not *all* types in the dictionary need
this mark, but it is sufficient for now.

Change-Id: I2d39456691f1c3df8efe3bddc3b9017e0ef37a7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/336012
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
src/cmd/compile/internal/noder/stencil.go