1
0
mirror of https://github.com/golang/go synced 2024-11-19 13:04:45 -07:00

cmd/compile: improve regalloc live values debug printing

Before:

live values at end of each block
  b1: v3 v2 v7 avoid=0
  b2: v3 v13 avoid=81
  b3: v19[AX] v3 avoid=81
  b6: avoid=0
  b7: avoid=0
  b5: avoid=0
  b4: v3 v18 avoid=81

After:

live values at end of each block
  b1: v3 v2 v7
  b2: v3 v13 avoid=AX DI
  b3: v19[AX] v3 avoid=AX DI
  b6:
  b7:
  b5:
  b4: v3 v18 avoid=AX DI

Change-Id: Ibec5c76a16151832b8d49a21c640699fdc9a9d28
Reviewed-on: https://go-review.googlesource.com/109000
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2018-04-17 09:09:07 -07:00
parent 3bf1644428
commit 3d6647d6f8

View File

@ -165,6 +165,21 @@ func (m regMask) String() string {
return s
}
func (s *regAllocState) RegMaskString(m regMask) string {
str := ""
for r := register(0); m != 0; r++ {
if m>>r&1 == 0 {
continue
}
m &^= regMask(1) << r
if str != "" {
str += " "
}
str += s.registers[r].String()
}
return str
}
// countRegs returns the number of set bits in the register mask.
func countRegs(r regMask) int {
n := 0
@ -793,7 +808,7 @@ func (s *regAllocState) regalloc(f *Func) {
}
}
if s.f.pass.debug > regDebug {
fmt.Printf("uses for %s:%s\n", s.f.Name, b)
fmt.Printf("use distances for %s\n", b)
for i := range s.values {
vi := &s.values[i]
u := vi.uses
@ -2400,7 +2415,9 @@ func (s *regAllocState) computeLive() {
fmt.Printf("]")
}
}
fmt.Printf(" avoid=%x", int64(s.desired[b.ID].avoid))
if avoid := s.desired[b.ID].avoid; avoid != 0 {
fmt.Printf(" avoid=%v", s.RegMaskString(avoid))
}
fmt.Println()
}
}