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 | 821b8560e735613dfcf7670866f9142e4845037e (patch) | |
tree | c55235dae97955001b6989b5085bf79f40556b10 /lib/CodeGen | |
parent | 8e10844ad0341fa4b0a1264324a3614903d8ff9e (diff) | |
download | external_llvm-821b8560e735613dfcf7670866f9142e4845037e.zip external_llvm-821b8560e735613dfcf7670866f9142e4845037e.tar.gz external_llvm-821b8560e735613dfcf7670866f9142e4845037e.tar.bz2 |
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')
-rw-r--r-- | lib/CodeGen/VirtRegMap.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/CodeGen/VirtRegMap.cpp b/lib/CodeGen/VirtRegMap.cpp index 461d839..aae13d8 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 |