summaryrefslogtreecommitdiff
path: root/lib/CodeGen/VirtRegMap.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2009-03-08 03:58:35 +0000
committerEvan Cheng <evan.cheng@apple.com>2009-03-08 03:58:35 +0000
commit821b8560e735613dfcf7670866f9142e4845037e (patch)
treec55235dae97955001b6989b5085bf79f40556b10 /lib/CodeGen/VirtRegMap.cpp
parent8e10844ad0341fa4b0a1264324a3614903d8ff9e (diff)
downloadllvm-821b8560e735613dfcf7670866f9142e4845037e.tar.gz
llvm-821b8560e735613dfcf7670866f9142e4845037e.tar.bz2
llvm-821b8560e735613dfcf7670866f9142e4845037e.tar.xz
If a MI uses the same register more than once, only mark one of them as 'kill'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66363 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/VirtRegMap.cpp')
-rw-r--r--lib/CodeGen/VirtRegMap.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/CodeGen/VirtRegMap.cpp b/lib/CodeGen/VirtRegMap.cpp
index 461d839f1c..aae13d8da6 100644
--- a/lib/CodeGen/VirtRegMap.cpp
+++ b/lib/CodeGen/VirtRegMap.cpp
@@ -1317,6 +1317,23 @@ void LocalSpiller::TransferDeadness(MachineBasicBlock *MBB, unsigned CurDist,
}
}
+/// hasLaterNon2AddrUse - If the MI has another use of the specified virtual
+/// register later and it's not a two-address, return true. That means it's
+/// safe to mark the current use at 'i' isKill.
+static bool hasLaterNon2AddrUse(MachineInstr &MI, unsigned i, unsigned VirtReg){
+ const TargetInstrDesc &TID = MI.getDesc();
+
+ ++i;
+ for (unsigned e = TID.getNumOperands(); i != e; ++i) {
+ const MachineOperand &MO = MI.getOperand(i);
+ if (!MO.isReg() || MO.getReg() != VirtReg)
+ continue;
+ if (TID.getOperandConstraint(i, TOI::TIED_TO) == -1)
+ return true;
+ }
+ return false;
+}
+
/// rewriteMBB - Keep track of which spills are available even after the
/// register allocator is done with them. If possible, avid reloading vregs.
void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM,
@@ -1581,9 +1598,7 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM,
// apply, reuse it.
bool CanReuse = true;
int ti = TID.getOperandConstraint(i, TOI::TIED_TO);
- if (ti != -1 &&
- MI.getOperand(ti).isReg() &&
- MI.getOperand(ti).getReg() == VirtReg) {
+ if (ti != -1) {
// Okay, we have a two address operand. We can reuse this physreg as
// long as we are allowed to clobber the value and there isn't an
// earlier def that has already clobbered the physreg.
@@ -1637,9 +1652,10 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM,
PotentialDeadStoreSlots.push_back(ReuseSlot);
}
- // Assumes this is the last use. IsKill will be unset if reg is reused
- // unless it's a two-address operand.
- if (ti == -1)
+ // Mark is isKill if it's there no other uses of the same virtual
+ // register and it's not a two-address operand. IsKill will be
+ // unset if reg is reused.
+ if (ti == -1 && !hasLaterNon2AddrUse(MI, i, VirtReg))
MI.getOperand(i).setIsKill();
continue;
} // CanReuse