cmd/compile: discard duplicate inline method bodies
cmd/compile: discard duplicate inline method bodies

If we've already imported a named type, then there's no need to
process its associated methods except to validate that the signature
matches the existing known method.

However, the current import code still creates a new function node for
each method, saves its inline body (if any), and adds the node to the
global importlist. Because of this, the duplicate methods are never
garbage collected.

This CL changes the compiler to avoid amassing uncollectable garbage
or performing any unnecessary processing.

This is particularly noticeable for protobuf-heavy code. For the
motivating Go package, this CL reduced compile max-RSS from ~12GB to
~3GB and compile time from ~65s to ~50s.

Passes toolstash -cmp for std, cmd, and k8s.io/kubernetes/cmd/....

Change-Id: Ib53ba9f2ad3212995671cf6ba220ee8a56d8d009
Reviewed-on: https://go-review.googlesource.com/51331
Run-TryBot: Austin Clements <7ea35d812706d9213868749011af1ed4fa2f6aa0@google.com>
TryBot-Result: Gobot Gobot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Austin Clements <7ea35d812706d9213868749011af1ed4fa2f6aa0@google.com>

Cofyc/go,josharian/go,akutz/go,Cofyc/go,golang/go,polyverse-security/go,akutz/go,golang/go,nawawi/go,codestation/go,nawawi/go,akutz/go,golang/go,Cofyc/go,polyverse-security/go,cloudflare/go,codestation/go,josharian/go,codestation/go,CAFxX/go,golang/go,CAFxX/go,cloudflare/go,polyverse-security/go,Cofyc/go,codestation/go,cloudflare/go,akutz/go,akutz/go,polyverse-security/go,cloudflare/go,codestation/go,codestation/go,polyverse-security/go,cloudflare/go,akutz/go,polyverse-security/go,CAFxX/go,CAFxX/go,josharian/go,codestation/go,Cofyc/go,golang/go,nawawi/go,josharian/go,polyverse-security/go,nawawi/go,golang/go,akutz/go,cloudflare/go,nawawi/go,christopher-henderson/Go,josharian/go,Cofyc/go,akutz/go,Cofyc/go,cloudflare/go,codestation/go,CAFxX/go,CAFxX/go,nawawi/go,Cofyc/go,CAFxX/go,cloudflare/go,CAFxX/go,nawawi/go,josharian/go,josharian/go,polyverse-security/go,golang/go,josharian/go,nawawi/go,golang/go