Be less aggressive about hinting in RAFast.

In particular, don't spill dirty registers only to satisfy a hint. It is
not worth it.

The attached test case provides an example where the fast allocator
would spill a register when other registers are available.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132900 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen
2011-06-13 03:26:46 +00:00
parent 687397c013
commit 5e5ed44577
4 changed files with 59 additions and 9 deletions

View File

@@ -487,14 +487,12 @@ void RAFast::allocVirtReg(MachineInstr *MI, LiveRegEntry &LRE, unsigned Hint) {
// Take hint when possible.
if (Hint) {
switch(calcSpillCost(Hint)) {
default:
definePhysReg(MI, Hint, regFree);
// Fall through.
case 0:
// Ignore the hint if we would have to spill a dirty register.
unsigned Cost = calcSpillCost(Hint);
if (Cost < spillDirty) {
if (Cost)
definePhysReg(MI, Hint, regFree);
return assignVirtToPhysReg(LRE, Hint);
case spillImpossible:
break;
}
}