aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-12-11 23:36:57 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-12-11 23:36:57 +0000
commit39c883cfc52776fa9a553f7e7ff06816ed476adb (patch)
tree1c0bec44ab21fa0373eba1b8b45b7558dd3e898b
parentefe2be797699d77dc3387969aa566c26d5c36d9d (diff)
downloadexternal_llvm-39c883cfc52776fa9a553f7e7ff06816ed476adb.zip
external_llvm-39c883cfc52776fa9a553f7e7ff06816ed476adb.tar.gz
external_llvm-39c883cfc52776fa9a553f7e7ff06816ed476adb.tar.bz2
If deleting a reload instruction due to reuse (value is available in register R and reload is targeting R), make sure to invalidate the kill information of the last kill.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44894 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/VirtRegMap.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/CodeGen/VirtRegMap.cpp b/lib/CodeGen/VirtRegMap.cpp
index d0fd62a..9740043 100644
--- a/lib/CodeGen/VirtRegMap.cpp
+++ b/lib/CodeGen/VirtRegMap.cpp
@@ -474,6 +474,17 @@ static void InvalidateKills(MachineInstr &MI, BitVector &RegKills,
}
}
+/// InvalidateKill - A MI that defines the specified register is being deleted,
+/// invalidate the register kill information.
+static void InvalidateKill(unsigned Reg, BitVector &RegKills,
+ std::vector<MachineOperand*> &KillOps) {
+ if (RegKills[Reg]) {
+ KillOps[Reg]->unsetIsKill();
+ KillOps[Reg] = NULL;
+ RegKills.reset(Reg);
+ }
+}
+
/// InvalidateRegDef - If the def operand of the specified def MI is now dead
/// (since it's spill instruction is removed), mark it isDead. Also checks if
/// the def MI has other definition operands that are not dead. Returns it by
@@ -537,12 +548,13 @@ static void UpdateKills(MachineInstr &MI, BitVector &RegKills,
// That can't be right. Register is killed but not re-defined and it's
// being reused. Let's fix that.
KillOps[Reg]->unsetIsKill();
+ KillOps[Reg] = NULL;
+ RegKills.reset(Reg);
if (i < TID->numOperands &&
TID->getOperandConstraint(i, TOI::TIED_TO) == -1)
// Unless it's a two-address operand, this is the new kill.
MO.setIsKill();
}
-
if (MO.isKill()) {
RegKills.set(Reg);
KillOps[Reg] = &MO;
@@ -1261,8 +1273,11 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) {
NextMII = &MI;
--NextMII; // backtrack to the copy.
BackTracked = true;
- } else
+ } else {
DOUT << "Removing now-noop copy: " << MI;
+ // Unset last kill since it's being reused.
+ InvalidateKill(InReg, RegKills, KillOps);
+ }
VRM.RemoveMachineInstrFromMaps(&MI);
MBB.erase(&MI);
@@ -1298,6 +1313,7 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) {
// the value and there isn't an earlier def that has already clobbered the
// physreg.
if (PhysReg &&
+ !TII->isStoreToStackSlot(&MI, SS) && // Not profitable!
DeadStore->findRegisterUseOperandIdx(PhysReg, true) != -1 &&
MRI->unfoldMemoryOperand(MF, &MI, PhysReg, false, true, NewMIs)) {
MBB.insert(MII, NewMIs[0]);