summaryrefslogtreecommitdiff
path: root/lib/CodeGen/LiveIntervalAnalysis.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-02-25 09:46:31 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-02-25 09:46:31 +0000
commit48ef398ebd2f2b992c81bebd5159de119ce62c80 (patch)
tree6679859d96b4ba07c88066f04b125faeb3c9de02 /lib/CodeGen/LiveIntervalAnalysis.cpp
parent16191f03337645dc1638b7489d71d685e6c07cdd (diff)
downloadllvm-48ef398ebd2f2b992c81bebd5159de119ce62c80.tar.gz
llvm-48ef398ebd2f2b992c81bebd5159de119ce62c80.tar.bz2
llvm-48ef398ebd2f2b992c81bebd5159de119ce62c80.tar.xz
Fix a couple of bugs related IsDead back propagation during coalescing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34595 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveIntervalAnalysis.cpp')
-rw-r--r--lib/CodeGen/LiveIntervalAnalysis.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp
index 5e17a734a2..809d13464c 100644
--- a/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -903,11 +903,16 @@ bool LiveIntervals::JoinCopy(MachineInstr *CopyMI,
unsigned SrcStart = 0;
unsigned SrcEnd = 0;
if (isDead) {
- unsigned CopyIdx = getDefIndex(getInstructionIndex(CopyMI));
- LiveInterval::iterator SrcLR = SrcInt.FindLiveRangeContaining(CopyIdx-1);
+ unsigned CopyIdx = getInstructionIndex(CopyMI);
+ LiveInterval::iterator SrcLR =
+ SrcInt.FindLiveRangeContaining(getUseIndex(CopyIdx));
SrcStart = SrcLR->start;
SrcEnd = SrcLR->end;
- if (hasRegisterUse(repSrcReg, SrcStart, SrcEnd))
+ // The instruction which defines the src is only truly dead if there are
+ // no intermediate uses and there isn't a use beyond the copy.
+ // FIXME: find the last use, mark is kill and shorten the live range.
+ if (SrcEnd > getDefIndex(CopyIdx) ||
+ hasRegisterUse(repSrcReg, SrcStart, CopyIdx))
isDead = false;
}
@@ -918,10 +923,10 @@ bool LiveIntervals::JoinCopy(MachineInstr *CopyMI,
if (JoinIntervals(DestInt, SrcInt)) {
if (isDead) {
// Result of the copy is dead. Propagate this property.
- if (SrcStart == 0) {
+ if (SrcStart == 0 && MRegisterInfo::isPhysicalRegister(SrcReg)) {
// Live-in to the function but dead. Remove it from MBB live-in set.
// JoinIntervals may end up swapping the two intervals.
- LiveInterval &LiveInInt = (repSrcReg == DestInt.reg) ? DestInt:SrcInt;
+ LiveInterval &LiveInInt = (repSrcReg == DestInt.reg) ? DestInt : SrcInt;
LiveInInt.removeRange(SrcStart, SrcEnd);
MachineBasicBlock *MBB = CopyMI->getParent();
MBB->removeLiveIn(SrcReg);