From e2dc0c978e2435dbbb55cb7fca7750034c3e292a Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Wed, 2 Mar 2011 23:05:16 +0000 Subject: [PATCH] Extract a method. No functional change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126893 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SplitKit.cpp | 51 +++++++++++++++++++--------------------- lib/CodeGen/SplitKit.h | 4 ++++ 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/lib/CodeGen/SplitKit.cpp b/lib/CodeGen/SplitKit.cpp index 4c2a7bda0f6..c0612026d21 100644 --- a/lib/CodeGen/SplitKit.cpp +++ b/lib/CodeGen/SplitKit.cpp @@ -646,6 +646,29 @@ void SplitEditor::closeIntv() { OpenIdx = 0; } +void SplitEditor::extendPHIKillRanges() { + // Extend live ranges to be live-out for successor PHI values. + for (LiveInterval::const_vni_iterator I = Edit.getParent().vni_begin(), + E = Edit.getParent().vni_end(); I != E; ++I) { + const VNInfo *PHIVNI = *I; + if (PHIVNI->isUnused() || !PHIVNI->isPHIDef()) + continue; + unsigned RegIdx = RegAssign.lookup(PHIVNI->def); + MachineBasicBlock *MBB = LIS.getMBBFromIndex(PHIVNI->def); + for (MachineBasicBlock::pred_iterator PI = MBB->pred_begin(), + PE = MBB->pred_end(); PI != PE; ++PI) { + SlotIndex End = LIS.getMBBEndIdx(*PI).getPrevSlot(); + // The predecessor may not have a live-out value. That is OK, like an + // undef PHI operand. + if (Edit.getParent().liveAt(End)) { + assert(RegAssign.lookup(End) == RegIdx && + "Different register assignment in phi predecessor"); + extendRange(RegIdx, End); + } + } + } +} + /// rewriteAssigned - Rewrite all uses of Edit.getReg(). void SplitEditor::rewriteAssigned() { for (MachineRegisterInfo::reg_iterator RI = MRI.reg_begin(Edit.getReg()), @@ -737,34 +760,8 @@ void SplitEditor::finish() { // All other values have simple liveness that can be computed from RegAssign // and the parent live interval. - // Extend live ranges to be live-out for successor PHI values. - for (LiveInterval::const_vni_iterator I = Edit.getParent().vni_begin(), - E = Edit.getParent().vni_end(); I != E; ++I) { - const VNInfo *PHIVNI = *I; - if (PHIVNI->isUnused() || !PHIVNI->isPHIDef()) - continue; - unsigned RegIdx = RegAssign.lookup(PHIVNI->def); - MachineBasicBlock *MBB = LIS.getMBBFromIndex(PHIVNI->def); - DEBUG(dbgs() << " map phi in BB#" << MBB->getNumber() << '@' << PHIVNI->def - << " -> " << RegIdx << '\n'); - for (MachineBasicBlock::pred_iterator PI = MBB->pred_begin(), - PE = MBB->pred_end(); PI != PE; ++PI) { - SlotIndex End = LIS.getMBBEndIdx(*PI).getPrevSlot(); - DEBUG(dbgs() << " pred BB#" << (*PI)->getNumber() << '@' << End); - // The predecessor may not have a live-out value. That is OK, like an - // undef PHI operand. - if (Edit.getParent().liveAt(End)) { - DEBUG(dbgs() << " has parent live out\n"); - assert(RegAssign.lookup(End) == RegIdx && - "Different register assignment in phi predecessor"); - extendRange(RegIdx, End); - } else - DEBUG(dbgs() << " is not live-out\n"); - } - DEBUG(dbgs() << " " << *Edit.get(RegIdx) << '\n'); - } - // Rewrite instructions. + extendPHIKillRanges(); rewriteAssigned(); // FIXME: Delete defs that were rematted everywhere. diff --git a/lib/CodeGen/SplitKit.h b/lib/CodeGen/SplitKit.h index a0d935de1d2..3a4d710de9d 100644 --- a/lib/CodeGen/SplitKit.h +++ b/lib/CodeGen/SplitKit.h @@ -246,6 +246,10 @@ class SplitEditor { SlotIndex Idx, const MachineBasicBlock *IdxMBB); + /// extendPHIKillRanges - Extend the ranges of all values killed by original + /// parent PHIDefs. + void extendPHIKillRanges(); + /// rewriteAssigned - Rewrite all uses of Edit.getReg() to assigned registers. void rewriteAssigned();