cmd/compile: separate out sparsemaps that need position

Make them a separate type, so the normal sparse maps don't
need the extra storage.

Change-Id: I3a0219487c35ea63723499723b0c742e321d97c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/444819
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
Keith Randall 2022-10-21 14:16:41 -07:00 committed by Keith Randall
parent 9ce27feaeb
commit 7ddc45263c
8 changed files with 121 additions and 23 deletions

View file

@ -2498,10 +2498,10 @@ func (s *regAllocState) computeLive() {
s.desired = make([]desiredState, f.NumBlocks())
var phis []*Value
live := f.newSparseMap(f.NumValues())
defer f.retSparseMap(live)
t := f.newSparseMap(f.NumValues())
defer f.retSparseMap(t)
live := f.newSparseMapPos(f.NumValues())
defer f.retSparseMapPos(live)
t := f.newSparseMapPos(f.NumValues())
defer f.retSparseMapPos(t)
// Keep track of which value we want in each register.
var desired desiredState
@ -2630,7 +2630,7 @@ func (s *regAllocState) computeLive() {
d := e.val + delta
if !t.contains(e.key) || d < t.get(e.key) {
update = true
t.set(e.key, d, e.aux)
t.set(e.key, d, e.pos)
}
}
// Also add the correct arg from the saved phi values.
@ -2653,7 +2653,7 @@ func (s *regAllocState) computeLive() {
l = make([]liveInfo, 0, t.size())
}
for _, e := range t.contents() {
l = append(l, liveInfo{e.key, e.val, e.aux})
l = append(l, liveInfo{e.key, e.val, e.pos})
}
s.live[p.ID] = l
changed = true