aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/RegAllocLocal.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-05 00:49:09 +0000
committerChris Lattner <sabre@nondot.org>2003-08-05 00:49:09 +0000
commitd9ac6a7d3b6a022a2b3d0170c1a20c523c67b436 (patch)
tree09dc08b64867d0042f5d652362efd6e9965df820 /lib/CodeGen/RegAllocLocal.cpp
parent02beda12214997e2ac9586781e1f8d377744e6fa (diff)
Revert previous change, and be really anal about what physical registers can do.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7588 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegAllocLocal.cpp')
-rw-r--r--lib/CodeGen/RegAllocLocal.cpp46
1 files changed, 19 insertions, 27 deletions
diff --git a/lib/CodeGen/RegAllocLocal.cpp b/lib/CodeGen/RegAllocLocal.cpp
index f6eacda9c4..bf1670229a 100644
--- a/lib/CodeGen/RegAllocLocal.cpp
+++ b/lib/CodeGen/RegAllocLocal.cpp
@@ -232,28 +232,25 @@ void RA::removePhysReg(unsigned PhysReg) {
///
void RA::spillVirtReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator &I,
unsigned VirtReg, unsigned PhysReg) {
-
- DEBUG(std::cerr << " Spilling register " << RegInfo->getName(PhysReg));
- if (VirtReg == 0) {
- DEBUG(std::cerr << " which corresponds to no vreg, "
- << "must be spurious physreg: ignoring (WARNING)\n");
- } else {
- DEBUG(std::cerr << " containing %reg" << VirtReg;
- if (!isVirtRegModified(VirtReg))
- std::cerr << " which has not been modified, so no store necessary!");
-
- // Otherwise, there is a virtual register corresponding to this physical
- // register. We only need to spill it into its stack slot if it has been
- // modified.
- if (isVirtRegModified(VirtReg)) {
- const TargetRegisterClass *RC = MF->getSSARegMap()->getRegClass(VirtReg);
- int FrameIndex = getStackSpaceFor(VirtReg, RC);
- DEBUG(std::cerr << " to stack slot #" << FrameIndex);
- RegInfo->storeRegToStackSlot(MBB, I, PhysReg, FrameIndex, RC);
- ++NumSpilled; // Update statistics
- }
- Virt2PhysRegMap.erase(VirtReg); // VirtReg no longer available
+ assert((VirtReg || DisableKill) && "Spilling a physical register is illegal!"
+ " Must not have appropriate kill for the register or use exists beyond"
+ " the intended one.");
+ DEBUG(std::cerr << " Spilling register " << RegInfo->getName(PhysReg);
+ std::cerr << " containing %reg" << VirtReg;
+ if (!isVirtRegModified(VirtReg))
+ std::cerr << " which has not been modified, so no store necessary!");
+
+ // Otherwise, there is a virtual register corresponding to this physical
+ // register. We only need to spill it into its stack slot if it has been
+ // modified.
+ if (isVirtRegModified(VirtReg)) {
+ const TargetRegisterClass *RC = MF->getSSARegMap()->getRegClass(VirtReg);
+ int FrameIndex = getStackSpaceFor(VirtReg, RC);
+ DEBUG(std::cerr << " to stack slot #" << FrameIndex);
+ RegInfo->storeRegToStackSlot(MBB, I, PhysReg, FrameIndex, RC);
+ ++NumSpilled; // Update statistics
}
+ Virt2PhysRegMap.erase(VirtReg); // VirtReg no longer available
DEBUG(std::cerr << "\n");
removePhysReg(PhysReg);
@@ -510,12 +507,7 @@ void RA::AllocateBasicBlock(MachineBasicBlock &MBB) {
if (PhysReg) {
DEBUG(std::cerr << " Last use of " << RegInfo->getName(PhysReg)
<< "[%reg" << VirtReg <<"], removing it from live set\n");
- // If the physical register was used, but there was no definition of
- // the physical register (we are reading garbage), Live Variables will
- // tell us that this is the last use of the register even though we
- // don't know of anything in the register. No need to remove it.
- if (VirtReg != PhysReg || PhysRegsUsed.count(PhysReg))
- removePhysReg(PhysReg);
+ removePhysReg(PhysReg);
}
}
}