- for (LiveRegMap::iterator i = LiveVirtRegs.begin(), e = LiveVirtRegs.end();
- i != e; ++i)
- spillVirtReg(MBB, MI, i, true);
+ if (MI != MBB.end() && MI->getDesc().isReturn()) {
+ // This is a return block, kill all virtual registers.
+ DEBUG(dbgs() << "Killing live registers at end of return block.\n");
+ for (LiveRegMap::iterator i = LiveVirtRegs.begin(), e = LiveVirtRegs.end();
+ i != e; ++i)
+ killVirtReg(i);
+ } else {
+ // This is a normal block, spill any dirty virtregs.
+ DEBUG(dbgs() << "Spilling live registers at end of block.\n");
+ for (LiveRegMap::iterator i = LiveVirtRegs.begin(), e = LiveVirtRegs.end();
+ i != e; ++i)
+ spillVirtReg(MBB, MI, i, true);
+ }