]> Cypherpunks repositories - gostls13.git/commit
[dev.link] cmd/link: only read necessary fields in deadcode pass
authorCherry Zhang <cherryyz@google.com>
Fri, 7 Feb 2020 15:26:06 +0000 (10:26 -0500)
committerCherry Zhang <cherryyz@google.com>
Fri, 7 Feb 2020 20:39:23 +0000 (20:39 +0000)
commit38437ce118e60ff562406a771802e3ed466bd789
tree3a8dee700d71533a7d6ed1709b019e4d92d01e9f
parent06e2339dfee52361f5890c445c409b3731b1b9d2
[dev.link] cmd/link: only read necessary fields in deadcode pass

Reading unnecessary fields from object file take time, even from
memory mapping. In deadcode, we do this a alot, so only read
necessary ones. In particular, for relocations, for non-type
symbols, we only need their target symbols and reloc types to
build the dependency graph, so don't read other fields. This
should speed up the deadcode pass.

Also cache an object's number of defined package symbols, as it
is accessed a lot in resolve.

This is a bit ugly from an API point of view. It would be nice if
the compiler could figure out some fields are not used so don't
fill them.

Change-Id: I5c4e9526b8a3b0aead9fa71901a51fb214f013a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/218479
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/internal/goobj2/objfile.go
src/cmd/link/internal/ld/deadcode2.go
src/cmd/link/internal/loader/loader.go