diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2009-03-08 03:58:35 +0000 |
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2009-03-08 03:58:35 +0000 |
| commit | de22116f39d8656e02c1665cfecd5561e1d7ebe5 (patch) | |
| tree | f1a24e0877f1b5bd4d9c59dc1b1e6b04a4dcfc3d /llvm/lib/CodeGen | |
| parent | fee0a55c8473d6bb66459b125b89726ccaf4f76b (diff) | |
| download | bcm5719-llvm-de22116f39d8656e02c1665cfecd5561e1d7ebe5.tar.gz bcm5719-llvm-de22116f39d8656e02c1665cfecd5561e1d7ebe5.zip | |
If a MI uses the same register more than once, only mark one of them as 'kill'.
llvm-svn: 66363
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/VirtRegMap.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/VirtRegMap.cpp b/llvm/lib/CodeGen/VirtRegMap.cpp index 461d839f1c0..aae13d8da61 100644 --- a/llvm/lib/CodeGen/VirtRegMap.cpp +++ b/llvm/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 |

