summaryrefslogtreecommitdiff
path: root/lib/CodeGen/VirtRegMap.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-02-25 02:17:31 +0000
committerChris Lattner <sabre@nondot.org>2006-02-25 02:17:31 +0000
commit28bad084118a9746df95084364d7d95de00c3b67 (patch)
tree43eb450332c253fe73ea9e333bd27f7fa7f40137 /lib/CodeGen/VirtRegMap.cpp
parent47cb7173ea48691343b1046a0228a87c03b4167e (diff)
downloadllvm-28bad084118a9746df95084364d7d95de00c3b67.tar.gz
llvm-28bad084118a9746df95084364d7d95de00c3b67.tar.bz2
llvm-28bad084118a9746df95084364d7d95de00c3b67.tar.xz
Fix a bug that Evan exposed with some changes he's making, and that was
exposed with a fastcc problem (breaking pcompress2 on x86 with -enable-x86-fastcc). When reloading a reused reg, make sure to invalidate the reloaded reg, and check to see if there are any other pending uses of the same register. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26369 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/VirtRegMap.cpp')
-rw-r--r--lib/CodeGen/VirtRegMap.cpp32
1 files changed, 23 insertions, 9 deletions
diff --git a/lib/CodeGen/VirtRegMap.cpp b/lib/CodeGen/VirtRegMap.cpp
index 144780129d..c3c1ad909d 100644
--- a/lib/CodeGen/VirtRegMap.cpp
+++ b/lib/CodeGen/VirtRegMap.cpp
@@ -437,25 +437,39 @@ namespace {
// to undo a previous reuse.
MachineBasicBlock *MBB = MI->getParent();
const TargetRegisterClass *AliasRC =
- MBB->getParent()->getSSARegMap()->getRegClass(Op.VirtReg);
- MRI->loadRegFromStackSlot(*MBB, MI, Op.AssignedPhysReg,
- Op.StackSlot, AliasRC);
- Spills.ClobberPhysReg(Op.AssignedPhysReg);
- Spills.ClobberPhysReg(Op.PhysRegReused);
+ MBB->getParent()->getSSARegMap()->getRegClass(Op.VirtReg);
+
+ // Copy Op out of the vector and remove it, we're going to insert an
+ // explicit load for it.
+ ReusedOp NewOp = Op;
+ Reuses.erase(Reuses.begin()+ro);
+
+ // Ok, we're going to try to reload the assigned physreg into the
+ // slot that we were supposed to in the first place. However, that
+ // register could hold a reuse. Check to see if it conflicts or
+ // would prefer us to use a different register.
+ unsigned NewPhysReg = GetRegForReload(NewOp.AssignedPhysReg,
+ MI, Spills, MaybeDeadStores);
+
+ MRI->loadRegFromStackSlot(*MBB, MI, NewPhysReg,
+ NewOp.StackSlot, AliasRC);
+ Spills.ClobberPhysReg(NewPhysReg);
+ Spills.ClobberPhysReg(NewOp.PhysRegReused);
// Any stores to this stack slot are not dead anymore.
- MaybeDeadStores.erase(Op.StackSlot);
+ MaybeDeadStores.erase(NewOp.StackSlot);
- MI->SetMachineOperandReg(Op.Operand, Op.AssignedPhysReg);
+ MI->SetMachineOperandReg(NewOp.Operand, NewPhysReg);
- Spills.addAvailable(Op.StackSlot, Op.AssignedPhysReg);
+ Spills.addAvailable(NewOp.StackSlot, NewPhysReg);
++NumLoads;
DEBUG(MachineBasicBlock::iterator MII = MI;
std::cerr << '\t' << *prior(MII));
DEBUG(std::cerr << "Reuse undone!\n");
- Reuses.erase(Reuses.begin()+ro);
--NumReused;
+
+ // Finally, PhysReg is now available, go ahead and use it.
return PhysReg;
}
}