summaryrefslogtreecommitdiff
path: root/lib/CodeGen/TwoAddressInstructionPass.cpp
diff options
context:
space:
mode:
authorCameron Zwarich <zwarich@apple.com>2013-02-21 07:02:28 +0000
committerCameron Zwarich <zwarich@apple.com>2013-02-21 07:02:28 +0000
commit3a9805f26ead8746cb56645cb909a7b64d165b83 (patch)
treeb7e639575c439be8cf1f72f8854e9771ae8dde6a /lib/CodeGen/TwoAddressInstructionPass.cpp
parent7f838bbe450a28aba8769550a78219d3109c4a4e (diff)
downloadllvm-3a9805f26ead8746cb56645cb909a7b64d165b83.tar.gz
llvm-3a9805f26ead8746cb56645cb909a7b64d165b83.tar.bz2
llvm-3a9805f26ead8746cb56645cb909a7b64d165b83.tar.xz
Split part of isKilled() into a separate function for use elsewhere.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175726 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/TwoAddressInstructionPass.cpp')
-rw-r--r--lib/CodeGen/TwoAddressInstructionPass.cpp50
1 files changed, 28 insertions, 22 deletions
diff --git a/lib/CodeGen/TwoAddressInstructionPass.cpp b/lib/CodeGen/TwoAddressInstructionPass.cpp
index d4108fb0d7..8d242ec51a 100644
--- a/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/lib/CodeGen/TwoAddressInstructionPass.cpp
@@ -330,6 +330,33 @@ static bool isCopyToReg(MachineInstr &MI, const TargetInstrInfo *TII,
return true;
}
+/// isPLainlyKilled - Test if the given register value, which is used by the
+// given instruction, is killed by the given instruction.
+static bool isPlainlyKilled(MachineInstr *MI, unsigned Reg,
+ LiveIntervals *LIS) {
+ if (LIS && TargetRegisterInfo::isVirtualRegister(Reg) &&
+ !LIS->isNotInMIMap(MI)) {
+ // FIXME: Sometimes tryInstructionTransform() will add instructions and
+ // test whether they can be folded before keeping them. In this case it
+ // sets a kill before recursively calling tryInstructionTransform() again.
+ // If there is no interval available, we assume that this instruction is
+ // one of those. A kill flag is manually inserted on the operand so the
+ // check below will handle it.
+ LiveInterval &LI = LIS->getInterval(Reg);
+ // This is to match the kill flag version where undefs don't have kill
+ // flags.
+ if (!LI.hasAtLeastOneValue())
+ return false;
+
+ SlotIndex useIdx = LIS->getInstructionIndex(MI);
+ LiveInterval::const_iterator I = LI.find(useIdx);
+ assert(I != LI.end() && "Reg must be live-in to use.");
+ return SlotIndex::isSameInstr(I->end, useIdx);
+ }
+
+ return MI->killsRegister(Reg);
+}
+
/// isKilled - Test if the given register value, which is used by the given
/// instruction, is killed by the given instruction. This looks through
/// coalescable copies to see if the original value is potentially not killed.
@@ -351,29 +378,8 @@ static bool isKilled(MachineInstr &MI, unsigned Reg,
LiveIntervals *LIS) {
MachineInstr *DefMI = &MI;
for (;;) {
- if (LIS && TargetRegisterInfo::isVirtualRegister(Reg) &&
- !LIS->isNotInMIMap(DefMI)) {
- // FIXME: Sometimes tryInstructionTransform() will add instructions and
- // test whether they can be folded before keeping them. In this case it
- // sets a kill before recursively calling tryInstructionTransform() again.
- // If there is no interval available, we assume that this instruction is
- // one of those. A kill flag is manually inserted on the operand so the
- // check below will handle it.
- LiveInterval &LI = LIS->getInterval(Reg);
- // This is to match the kill flag version where undefs don't have kill
- // flags.
- if (!LI.hasAtLeastOneValue())
- return false;
-
- SlotIndex useIdx = LIS->getInstructionIndex(DefMI);
- LiveInterval::const_iterator I = LI.find(useIdx);
- assert(I != LI.end() && "Reg must be live-in to use.");
- if (!SlotIndex::isSameInstr(I->end, useIdx))
- return false;
- } else if (!DefMI->killsRegister(Reg)) {
+ if (!isPlainlyKilled(DefMI, Reg, LIS))
return false;
- }
-
if (TargetRegisterInfo::isPhysicalRegister(Reg))
return true;
MachineRegisterInfo::def_iterator Begin = MRI->def_begin(Reg);