Commit 3d6647d6 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

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: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 3bf16444
...@@ -165,6 +165,21 @@ func (m regMask) String() string { ...@@ -165,6 +165,21 @@ func (m regMask) String() string {
return s 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. // countRegs returns the number of set bits in the register mask.
func countRegs(r regMask) int { func countRegs(r regMask) int {
n := 0 n := 0
...@@ -793,7 +808,7 @@ func (s *regAllocState) regalloc(f *Func) { ...@@ -793,7 +808,7 @@ func (s *regAllocState) regalloc(f *Func) {
} }
} }
if s.f.pass.debug > regDebug { 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 { for i := range s.values {
vi := &s.values[i] vi := &s.values[i]
u := vi.uses u := vi.uses
...@@ -2400,7 +2415,9 @@ func (s *regAllocState) computeLive() { ...@@ -2400,7 +2415,9 @@ func (s *regAllocState) computeLive() {
fmt.Printf("]") 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() fmt.Println()
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment