diff options
author | Evan Cheng <evan.cheng@apple.com> | 2008-03-26 20:15:49 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2008-03-26 20:15:49 +0000 |
commit | 0c2843285269aa56a0781853cb25b6f03aa0bd99 (patch) | |
tree | d633b8bdd7656029492e102d085762a362417ead /lib/CodeGen/SimpleRegisterCoalescing.cpp | |
parent | ed70cbb3f367bc0f77d34d22163abbe4879526bc (diff) |
One more coalescer fix wrt deadness propagation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48837 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SimpleRegisterCoalescing.cpp')
-rw-r--r-- | lib/CodeGen/SimpleRegisterCoalescing.cpp | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/lib/CodeGen/SimpleRegisterCoalescing.cpp b/lib/CodeGen/SimpleRegisterCoalescing.cpp index 8ae36db115..aa5cda0265 100644 --- a/lib/CodeGen/SimpleRegisterCoalescing.cpp +++ b/lib/CodeGen/SimpleRegisterCoalescing.cpp @@ -554,6 +554,23 @@ void SimpleRegisterCoalescing::ShortenDeadCopyLiveRange(LiveInterval &li, } } +/// PropagateDeadness - Propagate the dead marker to the instruction which +/// defines the val#. +static void PropagateDeadness(LiveInterval &li, MachineInstr *CopyMI, + unsigned &LRStart, LiveIntervals *li_, + const TargetRegisterInfo* tri_) { + MachineInstr *DefMI = + li_->getInstructionFromIndex(li_->getDefIndex(LRStart)); + if (DefMI && DefMI != CopyMI) { + int DeadIdx = DefMI->findRegisterDefOperandIdx(li.reg, false, tri_); + if (DeadIdx != -1) { + DefMI->getOperand(DeadIdx).setIsDead(); + // A dead def should have a single cycle interval. + ++LRStart; + } + } +} + /// ShortenDeadCopyLiveRange - Shorten a live range as it's artificially /// extended by a dead copy. Mark the last use (if any) of the val# as kill /// as ends the live range there. If there isn't another use, then this @@ -613,23 +630,14 @@ SimpleRegisterCoalescing::ShortenDeadCopySrcLiveRange(LiveInterval &li, // Live-in to the function but dead. Remove it from entry live-in set. mf_->begin()->removeLiveIn(li.reg); } - removeRange(li, LR->start, LR->end, li_, tri_); // FIXME: Shorten intervals in BBs that reaches this BB. - } else { - // Not livein into BB. - MachineInstr *DefMI = - li_->getInstructionFromIndex(li_->getDefIndex(RemoveStart)); - if (DefMI && DefMI != CopyMI) { - int DeadIdx = DefMI->findRegisterDefOperandIdx(li.reg, false, tri_); - if (DeadIdx != -1) { - DefMI->getOperand(DeadIdx).setIsDead(); - // A dead def should have a single cycle interval. - ++RemoveStart; - } - } - removeRange(li, RemoveStart, LR->end, li_, tri_); } + if (LR->valno->def == RemoveStart) + // If the def MI defines the val#, propagate the dead marker. + PropagateDeadness(li, CopyMI, RemoveStart, li_, tri_); + + removeRange(li, RemoveStart, LR->end, li_, tri_); removeIntervalIfEmpty(li, li_, tri_); } |