]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: mark concrete call of reflect.(*rtype).Method as REFLECTMETHOD
authorCherry Zhang <cherryyz@google.com>
Wed, 10 Feb 2021 17:43:18 +0000 (12:43 -0500)
committerCherry Zhang <cherryyz@google.com>
Wed, 10 Feb 2021 22:44:54 +0000 (22:44 +0000)
commited8079096fe2e78d6dcb8002758774dca6d24eee
tree8dc44dbf7b93e21b65911270c6f032705dc5375b
parente9c96835971044aa4ace37c7787de231bbde05d9
cmd/compile: mark concrete call of reflect.(*rtype).Method as REFLECTMETHOD

For functions that call reflect.Type.Method (or MethodByName), we
mark it as REFLECTMETHOD, which tells the linker that methods
can be retrieved via reflection and the linker keeps all exported
methods live. Currently, this marking expects exactly the
interface call reflect.Type.Method (or MethodByName). But now the
compiler can devirtualize that call to a concrete call
reflect.(*rtype).Method (or MethodByName), which is not handled
and causing the linker to discard methods too aggressively.
Handle the latter in this CL.

Fixes #44207.

Change-Id: Ia4060472dbff6ab6a83d2ca8e60a3e3f180ee832
Reviewed-on: https://go-review.googlesource.com/c/go/+/290950
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/walk.go
test/reflectmethod7.go [new file with mode: 0644]