]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: do not flag reflect.StructOf() as a ReflectMethod.
authorDominique Lefevre <domingolefevre@gmail.com>
Thu, 24 Aug 2023 07:14:54 +0000 (10:14 +0300)
committerCherry Mui <cherryyz@google.com>
Tue, 29 Aug 2023 15:26:57 +0000 (15:26 +0000)
commit07faf8fab55d74ef6108e56b9e0ccee3e62b0a2d
treedaae0e5c79004de98bb0bc7cc6d0111824020e66
parent111ab754324e5d5646f84354bc1a134907baaa49
cmd/compile: do not flag reflect.StructOf() as a ReflectMethod.

StructOf() calls reflect.Type.Method(), but looks up only methods
accessible via interfaces. DCE does not remove such methods, so
there is no need to disable the DCE if StructOf() is used.

There is a dependency chain between struct rtype and StructOf():

  (*rtype).Method() -> FuncOf() -> initFuncTypes() -> StructOf().

Thus, any use of (*rtype).Method() or (*rtype).MethodByName()
disables the DCE in the linker. This is not an issue just yet
because all users of Method() and MethodByName() are flagged
as ReflectMethods. A subsequent patch avoids this flag on callers
of MethodByName(string literal). When that patch is applied,
it becomes important to have no ReflectMethods down the call
chain of MethodByName().

Change-Id: I9b3e55c495c122ed70ef31f9d978c0e2e0573799
Reviewed-on: https://go-review.googlesource.com/c/go/+/522435
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
src/cmd/compile/internal/walk/expr.go