]> Cypherpunks repositories - gostls13.git/commit
cmd/link: consider interface conversions only in reachable code
authorCherry Zhang <cherryyz@google.com>
Mon, 21 Sep 2020 03:29:20 +0000 (23:29 -0400)
committerCherry Zhang <cherryyz@google.com>
Mon, 28 Sep 2020 21:30:01 +0000 (21:30 +0000)
commitaf18bce87cc7ee1ffc68f91abefa241ab209539e
tree61998d0ad04ff13fd25f4466a5bcfa627b9d7569
parentad0ab812f8b80416c92ed227974e3194e98f4cdc
cmd/link: consider interface conversions only in reachable code

The linker prunes methods that are not directly reachable if the
receiver type is never converted to interface. Currently, this
"never" is too strong: it is invalidated even if the interface
conversion is in an unreachable function. This CL improves it by
only considering interface conversions in reachable code. To do
that, we introduce a marker relocation R_USEIFACE, which marks
the target symbol as UsedInIface if the source symbol is reached.

binary size    before      after
cmd/compile   18897528   18887400
cmd/go        13607372   13470652

Change-Id: I66c6b69eeff9ae02d84d2e6f2bc7f1b29dd53910
Reviewed-on: https://go-review.googlesource.com/c/go/+/256797
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
13 files changed:
src/cmd/compile/internal/gc/pgen.go
src/cmd/compile/internal/gc/sinit.go
src/cmd/compile/internal/gc/walk.go
src/cmd/internal/obj/s390x/asmz.go
src/cmd/internal/obj/wasm/wasmobj.go
src/cmd/internal/obj/x86/asm6.go
src/cmd/internal/objabi/reloctype.go
src/cmd/internal/objabi/reloctype_string.go
src/cmd/link/internal/ld/data.go
src/cmd/link/internal/ld/deadcode.go
src/cmd/link/internal/ld/testdata/deadcode/ifacemethod.go
src/cmd/link/internal/loader/loader.go
src/cmd/link/internal/wasm/asm.go