mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.link] cmd/link: add support to new deadcode for field tracking
Fix up the new dead code pass to include support for populating the ctxt "Reachparent" map, which is needed to support field tracking. Since we don't have sym.Symbols created at the point where new dead code runs, keep track of reachability using global symbol indices, and then once loader.LoadFull is complete we can translate the index mappings into symbol mappings. The fieldtracking output is unfortunately different relative to master, due to differences in the order in which symbols are encountered in deadcode, but I have eyeballed the results to make sure they look reasonable. Change-Id: I48c7a4597f05c00f15af3bfd37fc15ab4d0017c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/204342 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
63815923fc
commit
219922e95b
3 changed files with 39 additions and 15 deletions
|
|
@ -2611,6 +2611,22 @@ func (ctxt *Link) loadlibfull() {
|
|||
|
||||
setupdynexp(ctxt)
|
||||
|
||||
// Populate ctxt.Reachparent if appropriate.
|
||||
if ctxt.Reachparent != nil {
|
||||
for i := 0; i < len(ctxt.loader.Reachparent); i++ {
|
||||
p := ctxt.loader.Reachparent[i]
|
||||
if p == 0 {
|
||||
continue
|
||||
}
|
||||
if p == loader.Sym(i) {
|
||||
panic("self-cycle in reachparent")
|
||||
}
|
||||
sym := ctxt.loader.Syms[i]
|
||||
psym := ctxt.loader.Syms[p]
|
||||
ctxt.Reachparent[sym] = psym
|
||||
}
|
||||
}
|
||||
|
||||
// Drop the reference.
|
||||
ctxt.loader = nil
|
||||
ctxt.cgodata = nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue