aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2011-07-01 02:35:06 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2011-07-01 02:35:06 +0000
commit1c8b97cbc03e0e1966d244a27b55e74bde35671e (patch)
tree01a0c109b290aa88e1542674e381a8dc4a779c63 /lib
parent5e9ae090d8afd994c8c8e81779dd2c074ecf9369 (diff)
downloadexternal_llvm-1c8b97cbc03e0e1966d244a27b55e74bde35671e.zip
external_llvm-1c8b97cbc03e0e1966d244a27b55e74bde35671e.tar.gz
external_llvm-1c8b97cbc03e0e1966d244a27b55e74bde35671e.tar.bz2
Check the liveinterval, not the kill flag.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134228 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/RegisterCoalescer.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/CodeGen/RegisterCoalescer.cpp b/lib/CodeGen/RegisterCoalescer.cpp
index 57156cb..76edc08 100644
--- a/lib/CodeGen/RegisterCoalescer.cpp
+++ b/lib/CodeGen/RegisterCoalescer.cpp
@@ -1197,7 +1197,8 @@ static unsigned ComputeUltimateVN(VNInfo *VNI,
// which allows us to coalesce A and B.
// MI is the definition of B. LR is the life range of A that includes
// the slot just before B. If we return true, we add "B = X" to DupCopies.
-static bool RegistersDefinedFromSameValue(const TargetRegisterInfo &tri,
+static bool RegistersDefinedFromSameValue(LiveIntervals &li,
+ const TargetRegisterInfo &tri,
CoalescerPair &CP, MachineInstr *MI,
LiveRange *LR,
SmallVector<MachineInstr*, 8> &DupCopies) {
@@ -1207,14 +1208,16 @@ static bool RegistersDefinedFromSameValue(const TargetRegisterInfo &tri,
if (!MI->isFullCopy() || CP.isPartial() || CP.isPhys())
return false;
+ unsigned Dst = MI->getOperand(0).getReg();
+ unsigned Src = MI->getOperand(1).getReg();
+
// FIXME: If "B = X" kills X, we have to move the kill back to its
// previous use. For now we just avoid the optimization in that case.
- if (MI->getOperand(1).isKill())
+ SlotIndex CopyIdx = li.getInstructionIndex(MI).getNextIndex().getDefIndex();
+ LiveInterval &SrcInt = li.getInterval(Src);
+ if (SrcInt.killedAt(CopyIdx))
return false;
- unsigned Dst = MI->getOperand(0).getReg();
- unsigned Src = MI->getOperand(1).getReg();
-
if (!TargetRegisterInfo::isVirtualRegister(Src) ||
!TargetRegisterInfo::isVirtualRegister(Dst))
return false;
@@ -1332,7 +1335,7 @@ bool RegisterCoalescer::JoinIntervals(CoalescerPair &CP) {
// from the RHS interval, we can use its value #.
MachineInstr *MI = VNI->getCopy();
if (!CP.isCoalescable(MI) &&
- !RegistersDefinedFromSameValue(*tri_, CP, MI, lr, DupCopies))
+ !RegistersDefinedFromSameValue(*li_, *tri_, CP, MI, lr, DupCopies))
continue;
LHSValsDefinedFromRHS[VNI] = lr->valno;
@@ -1359,7 +1362,7 @@ bool RegisterCoalescer::JoinIntervals(CoalescerPair &CP) {
// from the LHS interval, we can use its value #.
MachineInstr *MI = VNI->getCopy();
if (!CP.isCoalescable(MI) &&
- !RegistersDefinedFromSameValue(*tri_, CP, MI, lr, DupCopies))
+ !RegistersDefinedFromSameValue(*li_, *tri_, CP, MI, lr, DupCopies))
continue;
RHSValsDefinedFromLHS[VNI] = lr->valno;