diff options
author | Evan Cheng <evan.cheng@apple.com> | 2011-11-16 03:05:12 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2011-11-16 03:05:12 +0000 |
commit | ae7db7af44c9155092d4b80cb4d5d333469f4320 (patch) | |
tree | 7e054c421e1c2ac2f16605812b9f72892b04a3c4 /lib/CodeGen/TwoAddressInstructionPass.cpp | |
parent | ee94dc212e67a6db3a8ee3f52346e147eeb5c010 (diff) | |
download | llvm-ae7db7af44c9155092d4b80cb4d5d333469f4320.tar.gz llvm-ae7db7af44c9155092d4b80cb4d5d333469f4320.tar.bz2 llvm-ae7db7af44c9155092d4b80cb4d5d333469f4320.tar.xz |
Process all uses first before defs to accurately capture register liveness. rdar://10449480
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144770 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/TwoAddressInstructionPass.cpp')
-rw-r--r-- | lib/CodeGen/TwoAddressInstructionPass.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/CodeGen/TwoAddressInstructionPass.cpp b/lib/CodeGen/TwoAddressInstructionPass.cpp index e2fd0076cd..2e5111dee5 100644 --- a/lib/CodeGen/TwoAddressInstructionPass.cpp +++ b/lib/CodeGen/TwoAddressInstructionPass.cpp @@ -1115,6 +1115,7 @@ TwoAddressInstructionPass::RescheduleKillAboveMI(MachineBasicBlock *MBB, MCID.isTerminator()) // Don't move pass calls, etc. return false; + SmallVector<unsigned, 2> OtherDefs; for (unsigned i = 0, e = OtherMI->getNumOperands(); i != e; ++i) { const MachineOperand &MO = OtherMI->getOperand(i); if (!MO.isReg()) @@ -1131,15 +1132,20 @@ TwoAddressInstructionPass::RescheduleKillAboveMI(MachineBasicBlock *MBB, // Don't want to extend other live ranges and update kills. return false; } else { - if (Uses.count(MOReg)) - return false; - if (TargetRegisterInfo::isPhysicalRegister(MOReg) && - LiveDefs.count(MOReg)) - return false; - // Physical register def is seen. - Defs.erase(MOReg); + OtherDefs.push_back(MOReg); } } + + for (unsigned i = 0, e = OtherDefs.size(); i != e; ++i) { + unsigned MOReg = OtherDefs[i]; + if (Uses.count(MOReg)) + return false; + if (TargetRegisterInfo::isPhysicalRegister(MOReg) && + LiveDefs.count(MOReg)) + return false; + // Physical register def is seen. + Defs.erase(MOReg); + } } // Move the old kill above MI, don't forget to move debug info as well. |