[dev.ssa] cmd/compile: memory allocation tweaks to regalloc and dom

Spotted a minor source of excess allocation in the register
allocator.  Rearranged the dominator tree code to pull its
scratch memory from a reused buffer attached to Config.

Change-Id: I6da6e7b112f7d3eb1fd00c58faa8214cdea44e38
Reviewed-on: https://go-review.googlesource.com/19450
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
David Chase 2016-02-10 17:43:31 -05:00
parent 94f0245114
commit b86cafc7dc
3 changed files with 74 additions and 20 deletions

View file

@ -964,7 +964,16 @@ func (s *regAllocState) regalloc(f *Func) {
}
// Save end-of-block register state.
var regList []endReg
// First count how many, this cuts allocations in half.
k := 0
for r := register(0); r < numRegs; r++ {
v := s.regs[r].v
if v == nil {
continue
}
k++
}
regList := make([]endReg, 0, k)
for r := register(0); r < numRegs; r++ {
v := s.regs[r].v
if v == nil {
@ -1609,8 +1618,8 @@ func (s *regAllocState) computeLive() {
}
// The live set has changed, update it.
l := s.live[p.ID][:0]
if cap(l) == 0 {
l = make([]liveInfo, 0, len(t.contents()))
if cap(l) < t.size() {
l = make([]liveInfo, 0, t.size())
}
for _, e := range t.contents() {
l = append(l, liveInfo{e.key, e.val})