diff options
author | Evan Cheng <evan.cheng@apple.com> | 2007-03-22 01:26:05 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2007-03-22 01:26:05 +0000 |
commit | 2c3535d2a6738d154914a59f272fac45e50b706b (patch) | |
tree | 6cbf8f8ff3237c1b473688f684027e0fb85b0847 /lib/CodeGen/LiveIntervalAnalysis.cpp | |
parent | 48e15e3cc6c66d99849218b5205960760f62d1b3 (diff) |
Fix for PR1257. Bug in live range shortening as a result of copy coalescing
where the destination is dead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35252 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveIntervalAnalysis.cpp')
-rw-r--r-- | lib/CodeGen/LiveIntervalAnalysis.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index a968063c99..ab8a18d1df 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -924,14 +924,14 @@ bool LiveIntervals::JoinCopy(MachineInstr *CopyMI, MachineOperand *mopd = CopyMI->findRegisterDefOperand(DstReg); bool isDead = mopd->isDead(); bool isShorten = false; - unsigned SrcStart = 0; - unsigned SrcEnd = 0; + unsigned SrcStart = 0, RemoveStart = 0; + unsigned SrcEnd = 0, RemoveEnd = 0; if (isDead) { unsigned CopyIdx = getInstructionIndex(CopyMI); LiveInterval::iterator SrcLR = SrcInt.FindLiveRangeContaining(getUseIndex(CopyIdx)); - SrcStart = SrcLR->start; - SrcEnd = SrcLR->end; + RemoveStart = SrcStart = SrcLR->start; + RemoveEnd = SrcEnd = SrcLR->end; // 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. @@ -939,18 +939,16 @@ bool LiveIntervals::JoinCopy(MachineInstr *CopyMI, isDead = false; else { MachineOperand *MOU; - MachineInstr *LastUse = - lastRegisterUse(repSrcReg, SrcStart, CopyIdx, MOU); + MachineInstr *LastUse= lastRegisterUse(repSrcReg, SrcStart, CopyIdx, MOU); if (LastUse) { // Shorten the liveinterval to the end of last use. MOU->setIsKill(); isDead = false; isShorten = true; - SrcEnd = getUseIndex(getInstructionIndex(LastUse)); + RemoveStart = getDefIndex(getInstructionIndex(LastUse)); + RemoveEnd = SrcEnd; } } - if (isDead) - isShorten = true; } // We need to be careful about coalescing a source physical register with a @@ -1030,10 +1028,10 @@ TryJoin: } } - if (isShorten) { + if (isShorten || isDead) { // Shorten the live interval. LiveInterval &LiveInInt = (repSrcReg == DestInt.reg) ? DestInt : SrcInt; - LiveInInt.removeRange(SrcStart, SrcEnd); + LiveInInt.removeRange(RemoveStart, RemoveEnd); } } else { // Coallescing failed. |