summaryrefslogtreecommitdiff
path: root/lib/CodeGen/RegAllocFast.cpp
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2010-09-03 21:45:15 +0000
committerJim Grosbach <grosbach@apple.com>2010-09-03 21:45:15 +0000
commitee72651df4b783c973bb682bef7eab2ff9a703e2 (patch)
tree1ee0327efc74c46d5b17ebe13befd487438e1686 /lib/CodeGen/RegAllocFast.cpp
parentcaa9ba228d9d8326cd54457be6e9c2ae313db75c (diff)
downloadllvm-ee72651df4b783c973bb682bef7eab2ff9a703e2.tar.gz
llvm-ee72651df4b783c973bb682bef7eab2ff9a703e2.tar.bz2
llvm-ee72651df4b783c973bb682bef7eab2ff9a703e2.tar.xz
previous patch was a little too tricky for its own good. Don't try to
overload UserInInstr. Explicitly check Allocatable. The early exit in the condition will mean the performance impact of the extra test should be minimal. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113016 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegAllocFast.cpp')
-rw-r--r--lib/CodeGen/RegAllocFast.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/CodeGen/RegAllocFast.cpp b/lib/CodeGen/RegAllocFast.cpp
index 3cf1d726ec..fc150d55e2 100644
--- a/lib/CodeGen/RegAllocFast.cpp
+++ b/lib/CodeGen/RegAllocFast.cpp
@@ -113,9 +113,6 @@ namespace {
// Allocatable - vector of allocatable physical registers.
BitVector Allocatable;
- // Reserved - vector of reserved physical registers.
- BitVector Reserved;
-
// SkippedInstrs - Descriptors of instructions whose clobber list was
// ignored because all registers were spilled. It is still necessary to
// mark all the clobbered registers as used by the function.
@@ -501,7 +498,8 @@ void RAFast::allocVirtReg(MachineInstr *MI, LiveRegEntry &LRE, unsigned Hint) {
// First try to find a completely free register.
for (TargetRegisterClass::iterator I = AOB; I != AOE; ++I) {
unsigned PhysReg = *I;
- if (PhysRegState[PhysReg] == regFree && !UsedInInstr.test(PhysReg))
+ if (PhysRegState[PhysReg] == regFree && !UsedInInstr.test(PhysReg) &&
+ Allocatable.test(PhysReg))
return assignVirtToPhysReg(LRE, PhysReg);
}
@@ -510,6 +508,8 @@ void RAFast::allocVirtReg(MachineInstr *MI, LiveRegEntry &LRE, unsigned Hint) {
unsigned BestReg = 0, BestCost = spillImpossible;
for (TargetRegisterClass::iterator I = AOB; I != AOE; ++I) {
+ if (!Allocatable.test(*I))
+ continue;
unsigned Cost = calcSpillCost(*I);
// Cost is 0 when all aliases are already disabled.
if (Cost == 0)
@@ -712,7 +712,7 @@ void RAFast::handleThroughOperands(MachineInstr *MI,
}
// Restore UsedInInstr to a state usable for allocating normal virtual uses.
- UsedInInstr = Reserved;
+ UsedInInstr.reset();
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
MachineOperand &MO = MI->getOperand(i);
if (!MO.isReg() || (MO.isDef() && !MO.isEarlyClobber())) continue;
@@ -838,7 +838,7 @@ void RAFast::AllocateBasicBlock() {
}
// Track registers used by instruction.
- UsedInInstr = Reserved;
+ UsedInInstr.reset();
// First scan.
// Mark physreg uses and early clobbers as used.
@@ -916,7 +916,7 @@ void RAFast::AllocateBasicBlock() {
// Track registers defined by instruction - early clobbers and tied uses at
// this point.
- UsedInInstr = Reserved;
+ UsedInInstr.reset();
if (hasEarlyClobbers) {
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
MachineOperand &MO = MI->getOperand(i);
@@ -1014,7 +1014,6 @@ bool RAFast::runOnMachineFunction(MachineFunction &Fn) {
UsedInInstr.resize(TRI->getNumRegs());
Allocatable = TRI->getAllocatableSet(*MF);
- Reserved = TRI->getReservedRegs(*MF);
// initialize the virtual->physical register map to have a 'null'
// mapping for all virtual registers