[llvm-commits] [llvm] r66376 - in /llvm/branches/Apple/Dib: lib/CodeGen/VirtRegMap.cpp test/CodeGen/ARM/2009-03-07-SpillerBug.ll
Bill Wendling
isanbard at gmail.com
Sun Mar 8 00:19:36 PST 2009
Author: void
Date: Sun Mar 8 03:19:36 2009
New Revision: 66376
URL: http://llvm.org/viewvc/llvm-project?rev=66376&view=rev
Log:
Merge r66363 into Dib:
If a MI uses the same register more than once, only mark one of them as 'kill'.
Added:
llvm/branches/Apple/Dib/test/CodeGen/ARM/2009-03-07-SpillerBug.ll
- copied unchanged from r66363, llvm/trunk/test/CodeGen/ARM/2009-03-07-SpillerBug.ll
Modified:
llvm/branches/Apple/Dib/lib/CodeGen/VirtRegMap.cpp
Modified: llvm/branches/Apple/Dib/lib/CodeGen/VirtRegMap.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/CodeGen/VirtRegMap.cpp?rev=66376&r1=66375&r2=66376&view=diff
==============================================================================
--- llvm/branches/Apple/Dib/lib/CodeGen/VirtRegMap.cpp (original)
+++ llvm/branches/Apple/Dib/lib/CodeGen/VirtRegMap.cpp Sun Mar 8 03:19:36 2009
@@ -1317,6 +1317,23 @@
}
}
+/// 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, avoid reloading vregs.
void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM,
@@ -1581,9 +1598,7 @@
// 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 @@
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
More information about the llvm-commits
mailing list