[llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
Evan Cheng
evan.cheng at apple.com
Wed Mar 21 18:26:22 PDT 2007
Changes in directory llvm/lib/CodeGen:
LiveIntervalAnalysis.cpp updated: 1.226 -> 1.227
---
Log message:
Fix for PR1257: http://llvm.org/PR1257 . Bug in live range shortening as a result of copy coalescing
where the destination is dead.
---
Diffs of the changes: (+9 -11)
LiveIntervalAnalysis.cpp | 20 +++++++++-----------
1 files changed, 9 insertions(+), 11 deletions(-)
Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.226 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.227
--- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.226 Tue Mar 20 03:13:50 2007
+++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Mar 21 20:26:05 2007
@@ -924,14 +924,14 @@
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 @@
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 @@
}
}
- 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.
More information about the llvm-commits
mailing list