summaryrefslogtreecommitdiff
path: root/lib/CodeGen/RegAllocFast.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2011-06-13 03:26:46 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2011-06-13 03:26:46 +0000
commit5e5ed4457749995b46d46e9769e657fcc0818e2c (patch)
treec97c95cd44a3fe2469a41fb69cf45e15125a20af /lib/CodeGen/RegAllocFast.cpp
parent687397c01387534e98d2e8332d4b91536290d778 (diff)
downloadllvm-5e5ed4457749995b46d46e9769e657fcc0818e2c.tar.gz
llvm-5e5ed4457749995b46d46e9769e657fcc0818e2c.tar.bz2
llvm-5e5ed4457749995b46d46e9769e657fcc0818e2c.tar.xz
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
Diffstat (limited to 'lib/CodeGen/RegAllocFast.cpp')
-rw-r--r--lib/CodeGen/RegAllocFast.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/CodeGen/RegAllocFast.cpp b/lib/CodeGen/RegAllocFast.cpp
index 97652036f9..65ebdf827d 100644
--- a/lib/CodeGen/RegAllocFast.cpp
+++ b/lib/CodeGen/RegAllocFast.cpp
@@ -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;
}
}