Better calculation of spill costs / selection of spill candidates.
authorBen.Lippmeier@anu.edu.au <unknown>
Thu, 13 Sep 2007 15:54:07 +0000 (15:54 +0000)
committerBen.Lippmeier@anu.edu.au <unknown>
Thu, 13 Sep 2007 15:54:07 +0000 (15:54 +0000)
commit220a12e946b80166d3fe20419091135cef01f668
tree15979c68f6b7f11fae69a1c22b90ccb8994f0ef5
parent2381528a3b655af6becce8c8b130c63217992137
Better calculation of spill costs / selection of spill candidates.

Use Chaitin's formula for calculation of spill costs.
  Cost to spill some vreg = (num writes + num reads) / degree of node

With 2 extra provisos:
  1) Don't spill vregs that live for only 1 instruction.
  2) Always prefer to spill vregs that live for a number of instructions
       more than 10 times the number of vregs in that class.

Proviso 2 is there to help deal with basic blocks containing very long
live ranges - SHA1 has live ranges > 1700 instructions. We don't ever
try to keep these long lived ranges in regs at the expense of others.

Because stack slots are allocated from a global pool, and there is no
slot coalescing yet, without this condition the allocation of SHA1 dosn't
converge fast enough and eventually runs out of stack slots.

Prior to this patch we were just choosing to spill the range with the
longest lifetime, so we didn't bump into this particular problem.
compiler/nativeGen/MachRegs.lhs
compiler/nativeGen/RegAllocColor.hs
compiler/nativeGen/RegAllocStats.hs
compiler/nativeGen/RegLiveness.hs
compiler/nativeGen/RegSpillCost.hs [new file with mode: 0644]