[llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
Evan Cheng
evan.cheng at apple.com
Sun Feb 25 01:46:47 PST 2007
Changes in directory llvm/lib/CodeGen:
LiveIntervalAnalysis.cpp updated: 1.214 -> 1.215
---
Log message:
Fix a couple of bugs related IsDead back propagation during coalescing.
---
Diffs of the changes: (+10 -5)
LiveIntervalAnalysis.cpp | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.214 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.215
--- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.214 Sun Feb 25 03:41:59 2007
+++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Sun Feb 25 03:46:31 2007
@@ -903,11 +903,16 @@
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 @@
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);
More information about the llvm-commits
mailing list