aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/internal/ld/deadcode.go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2019-09-28 22:42:35 -0400
committerCherry Zhang <cherryyz@google.com>2019-10-10 22:05:09 +0000
commit8a9be4921a3cc91c80c02bb5b4cf2ad129c0c7cc (patch)
treead2d93eab00815b71026cad0dbac503ba32f8489 /src/cmd/link/internal/ld/deadcode.go
parentf7659d49be1839314ddc3a8606f8d6b3ce211b6b (diff)
downloadgo-8a9be4921a3cc91c80c02bb5b4cf2ad129c0c7cc.tar.xz
[dev.link] cmd/link: use index for deadcode
Switch the deadcode pass to use indices instead of Symbol structures when using new object file format. Delay loading symbol relocations and contents fully after the deadcode pass. The next step is not to create Symbol structures until deadcode is done. Method tracking logic hasn't been implemented. Currently, all methods of a reachable type are live. Change-Id: Iffcd06ff84e6e52bd9eb24d1220d94234d18ab6b Reviewed-on: https://go-review.googlesource.com/c/go/+/198199 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/cmd/link/internal/ld/deadcode.go')
-rw-r--r--src/cmd/link/internal/ld/deadcode.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/cmd/link/internal/ld/deadcode.go b/src/cmd/link/internal/ld/deadcode.go
index a024e40dff..d0896fcf2c 100644
--- a/src/cmd/link/internal/ld/deadcode.go
+++ b/src/cmd/link/internal/ld/deadcode.go
@@ -50,6 +50,11 @@ func deadcode(ctxt *Link) {
ctxt.Logf("%5.2f deadcode\n", Cputime())
}
+ if *flagNewobj {
+ deadcode2(ctxt)
+ return
+ }
+
d := &deadcodepass{
ctxt: ctxt,
ifaceMethod: make(map[methodsig]bool),
@@ -118,6 +123,10 @@ func deadcode(ctxt *Link) {
}
}
+ addToTextp(ctxt)
+}
+
+func addToTextp(ctxt *Link) {
// Remove dead text but keep file information (z symbols).
textp := []*sym.Symbol{}
for _, s := range ctxt.Textp {