aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2011-07-03 05:26:42 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2011-07-03 05:26:42 +0000
commit65268575c419a890052a446d28329f9e81302a05 (patch)
tree54d307cee3840aecdc0d1983eac3ee0611b319cc /lib/CodeGen
parent78e4fcecef1f0b2808a8a1c2b7ecab8d387efa88 (diff)
downloadexternal_llvm-65268575c419a890052a446d28329f9e81302a05.zip
external_llvm-65268575c419a890052a446d28329f9e81302a05.tar.gz
external_llvm-65268575c419a890052a446d28329f9e81302a05.tar.bz2
Fix an easy fixme.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134364 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/RegisterCoalescer.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/CodeGen/RegisterCoalescer.cpp b/lib/CodeGen/RegisterCoalescer.cpp
index 3b2046a..b91f92c 100644
--- a/lib/CodeGen/RegisterCoalescer.cpp
+++ b/lib/CodeGen/RegisterCoalescer.cpp
@@ -1214,12 +1214,6 @@ static bool RegistersDefinedFromSameValue(LiveIntervals &li,
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.
- LiveInterval &SrcInt = li.getInterval(Src);
- if (SrcInt.killedAt(VNI->def))
- return false;
-
if (!TargetRegisterInfo::isVirtualRegister(Src) ||
!TargetRegisterInfo::isVirtualRegister(Dst))
return false;
@@ -1253,6 +1247,7 @@ static bool RegistersDefinedFromSameValue(LiveIntervals &li,
// If the copies use two different value numbers of X, we cannot merge
// A and B.
+ LiveInterval &SrcInt = li.getInterval(Src);
if (SrcInt.getVNInfoAt(Other->def) != SrcInt.getVNInfoAt(VNI->def))
return false;
@@ -1476,6 +1471,7 @@ bool RegisterCoalescer::JoinIntervals(CoalescerPair &CP) {
if (RHSValNoAssignments.empty())
RHSValNoAssignments.push_back(-1);
+ SmallVector<unsigned, 8> SourceRegisters;
for (SmallVector<MachineInstr*, 8>::iterator I = DupCopies.begin(),
E = DupCopies.end(); I != E; ++I) {
MachineInstr *MI = *I;
@@ -1489,11 +1485,19 @@ bool RegisterCoalescer::JoinIntervals(CoalescerPair &CP) {
// X = X
// and mark the X as coalesced to keep the illusion.
unsigned Src = MI->getOperand(1).getReg();
+ SourceRegisters.push_back(Src);
MI->getOperand(0).substVirtReg(Src, 0, *tri_);
markAsJoined(MI);
}
+ // If B = X was the last use of X in a liverange, we have to shrink it now
+ // that B = X is gone.
+ for (SmallVector<unsigned, 8>::iterator I = SourceRegisters.begin(),
+ E = SourceRegisters.end(); I != E; ++I) {
+ li_->shrinkToUses(&li_->getInterval(*I));
+ }
+
// If we get here, we know that we can coalesce the live ranges. Ask the
// intervals to coalesce themselves now.
LHS.join(RHS, &LHSValNoAssignments[0], &RHSValNoAssignments[0], NewVNInfo,