[dev.ssa] cmd/compile: remember names of values

For debugging, spill values to named variables instead of autotmp_
variables if possible.  We do this by keeping a name -> value map
for each function, keep it up-to-date during deadcode elim, and use
it to override spill decisions in stackalloc.

It might even make stack frames a bit smaller, as it makes it easy
to identify a set of spills which are likely not to interfere.

This just works for one-word variables for now.  Strings/slices
will be a separate CL.

Change-Id: Ie89eba8cab16bcd41b311c479ec46dd7e64cdb67
Reviewed-on: https://go-review.googlesource.com/16336
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
Keith Randall 2015-10-22 14:22:38 -07:00
parent d43f2e37ed
commit c24681ae2e
10 changed files with 156 additions and 44 deletions

View file

@ -162,6 +162,25 @@ func deadcode(f *Func) {
}
f.Blocks = f.Blocks[:i]
// Remove dead entries from namedValues map.
for name, values := range f.NamedValues {
i := 0
for _, v := range values {
for v.Op == OpCopy {
v = v.Args[0]
}
if live[v.ID] {
values[i] = v
i++
}
}
f.NamedValues[name] = values[:i]
tail := values[i:]
for j := range tail {
tail[j] = nil
}
}
// TODO: renumber Blocks and Values densely?
// TODO: save dead Values and Blocks for reuse? Or should we just let GC handle it?
}