aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/VirtRegMap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/VirtRegMap.cpp')
-rw-r--r--lib/CodeGen/VirtRegMap.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/CodeGen/VirtRegMap.cpp b/lib/CodeGen/VirtRegMap.cpp
index a7154b2f06..68c4773673 100644
--- a/lib/CodeGen/VirtRegMap.cpp
+++ b/lib/CodeGen/VirtRegMap.cpp
@@ -276,7 +276,7 @@ namespace {
SmallSet<MachineInstr*, 4> &ReMatDefs,
BitVector &RegKills,
std::vector<MachineOperand*> &KillOps,
- VirtRegMap &VRM);
+ VirtRegMap &VRM, bool StoreMaybeDead);
void RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM);
};
}
@@ -860,7 +860,7 @@ void LocalSpiller::SpillRegToStackSlot(MachineBasicBlock &MBB,
SmallSet<MachineInstr*, 4> &ReMatDefs,
BitVector &RegKills,
std::vector<MachineOperand*> &KillOps,
- VirtRegMap &VRM) {
+ VirtRegMap &VRM, bool StoreMaybeDead) {
MRI->storeRegToStackSlot(MBB, next(MII), PhysReg, StackSlot, RC);
DOUT << "Store:\t" << *next(MII);
@@ -896,14 +896,15 @@ void LocalSpiller::SpillRegToStackSlot(MachineBasicBlock &MBB,
}
}
- LastStore = next(MII);
+ MachineInstr *NewStore = next(MII);
+ LastStore = StoreMaybeDead ? NewStore : NULL;
// If the stack slot value was previously available in some other
// register, change it now. Otherwise, make the register available,
// in PhysReg.
Spills.ModifyStackSlotOrReMat(StackSlot);
Spills.ClobberPhysReg(PhysReg);
- Spills.addAvailable(StackSlot, LastStore, PhysReg);
+ Spills.addAvailable(StackSlot, NewStore, PhysReg);
++NumStores;
}
@@ -985,8 +986,8 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) {
unsigned Phys = VRM.getPhys(VirtReg);
int StackSlot = VRM.getStackSlot(VirtReg);
MachineInstr *&LastStore = MaybeDeadStores[StackSlot];
- SpillRegToStackSlot(MBB, MII, i, Phys, StackSlot, RC,
- LastStore, Spills, ReMatDefs, RegKills, KillOps, VRM);
+ SpillRegToStackSlot(MBB, MII, i, Phys, StackSlot, RC, LastStore,
+ Spills, ReMatDefs, RegKills, KillOps, VRM, false);
}
}
@@ -1009,7 +1010,13 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) {
assert(MRegisterInfo::isVirtualRegister(VirtReg) &&
"Not a virtual or a physical register?");
-
+
+ // Assumes this is the last use of a split interval. IsKill will be unset
+ // if reg is use later unless it's a two-address operand.
+ if (MO.isUse() && VRM.getPreSplitReg(VirtReg) &&
+ TID->getOperandConstraint(i, TOI::TIED_TO) == -1)
+ MI.getOperand(i).setIsKill();
+
unsigned SubIdx = MO.getSubReg();
if (VRM.isAssignedReg(VirtReg)) {
// This virtual register was assigned a physreg!
@@ -1440,7 +1447,7 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) {
if (!MO.isDead()) {
MachineInstr *&LastStore = MaybeDeadStores[StackSlot];
SpillRegToStackSlot(MBB, MII, -1, PhysReg, StackSlot, RC, LastStore,
- Spills, ReMatDefs, RegKills, KillOps, VRM);
+ Spills, ReMatDefs, RegKills, KillOps, VRM, true);
// Check to see if this is a noop copy. If so, eliminate the
// instruction before considering the dest reg to be changed.