Fix a latent bug that my spiller patch last week exposed: we were leaving

instructions in the virtregfolded map that were deleted.  Because they
were deleted, newly allocated instructions could end up at the same address,
magically finding themselves in the map.  The solution is to remove entries
from the map when we delete the instructions.

llvm-svn: 28041
This commit is contained in:
Chris Lattner 2006-05-01 22:03:24 +00:00
parent ab7dbe0cc9
commit fd0a5478a1
2 changed files with 7 additions and 4 deletions

View File

@ -730,6 +730,7 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) {
assert(VirtRegMap::isMod && "Can't be modref!"); assert(VirtRegMap::isMod && "Can't be modref!");
DEBUG(std::cerr << "Removed dead store:\t" << *MDSI->second); DEBUG(std::cerr << "Removed dead store:\t" << *MDSI->second);
MBB.erase(MDSI->second); MBB.erase(MDSI->second);
VRM.RemoveFromFoldedVirtMap(MDSI->second);
MaybeDeadStores.erase(MDSI); MaybeDeadStores.erase(MDSI);
++NumDSE; ++NumDSE;
} }
@ -791,6 +792,7 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) {
++NumDCE; ++NumDCE;
DEBUG(std::cerr << "Removing now-noop copy: " << MI); DEBUG(std::cerr << "Removing now-noop copy: " << MI);
MBB.erase(&MI); MBB.erase(&MI);
VRM.RemoveFromFoldedVirtMap(&MI);
goto ProcessNextInst; goto ProcessNextInst;
} }
Spills.ClobberPhysReg(VirtReg); Spills.ClobberPhysReg(VirtReg);
@ -825,6 +827,7 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) {
++NumDCE; ++NumDCE;
DEBUG(std::cerr << "Removing now-noop copy: " << MI); DEBUG(std::cerr << "Removing now-noop copy: " << MI);
MBB.erase(&MI); MBB.erase(&MI);
VRM.RemoveFromFoldedVirtMap(&MI);
goto ProcessNextInst; goto ProcessNextInst;
} }
} }
@ -835,6 +838,7 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) {
DEBUG(std::cerr << "Removed dead store:\t" << *LastStore); DEBUG(std::cerr << "Removed dead store:\t" << *LastStore);
++NumDSE; ++NumDSE;
MBB.erase(LastStore); MBB.erase(LastStore);
VRM.RemoveFromFoldedVirtMap(LastStore);
} }
LastStore = next(MII); LastStore = next(MII);

View File

@ -137,11 +137,10 @@ namespace llvm {
return MI2VirtMap.equal_range(MI); return MI2VirtMap.equal_range(MI);
} }
/// RemoveFromFoldedVirtMap - Given a machine instruction in the folded /// RemoveFromFoldedVirtMap - If the specified machine instruction is in
/// instruction map, remove the entry in the folded instruction map. /// the folded instruction map, remove its entry from the map.
void RemoveFromFoldedVirtMap(MachineInstr *MI) { void RemoveFromFoldedVirtMap(MachineInstr *MI) {
bool ErasedAny = MI2VirtMap.erase(MI); MI2VirtMap.erase(MI);
assert(ErasedAny && "Machine instr not in folded vreg map!");
} }
void print(std::ostream &OS) const; void print(std::ostream &OS) const;