1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

LiveIntervalAnalysis: Add subregister aware variants pruneValue().

llvm-svn: 223886
This commit is contained in:
Matthias Braun 2014-12-10 01:12:36 +00:00
parent 3c79d93d70
commit b3f3f853d1
3 changed files with 32 additions and 15 deletions

View File

@ -164,14 +164,21 @@ namespace llvm {
/// See also LiveRangeCalc::extend(). /// See also LiveRangeCalc::extend().
void extendToIndices(LiveRange &LR, ArrayRef<SlotIndex> Indices); void extendToIndices(LiveRange &LR, ArrayRef<SlotIndex> Indices);
/// pruneValue - If an LI value is live at Kill, prune its live range by
/// removing any liveness reachable from Kill. Add live range end points to /// If @p LR has a live value at @p Kill, prune its live range by removing
/// any liveness reachable from Kill. Add live range end points to
/// EndPoints such that extendToIndices(LI, EndPoints) will reconstruct the /// EndPoints such that extendToIndices(LI, EndPoints) will reconstruct the
/// value's live range. /// value's live range.
/// ///
/// Calling pruneValue() and extendToIndices() can be used to reconstruct /// Calling pruneValue() and extendToIndices() can be used to reconstruct
/// SSA form after adding defs to a virtual register. /// SSA form after adding defs to a virtual register.
void pruneValue(LiveInterval *LI, SlotIndex Kill, void pruneValue(LiveRange &LR, SlotIndex Kill,
SmallVectorImpl<SlotIndex> *EndPoints);
/// Subregister aware variant of pruneValue(LiveRange &LR, SlotIndex Kill,
/// SmallVectorImpl<SlotIndex> &EndPoints). Prunes the value in the main
/// range and all sub ranges.
void pruneValue(LiveInterval &LI, SlotIndex Kill,
SmallVectorImpl<SlotIndex> *EndPoints); SmallVectorImpl<SlotIndex> *EndPoints);
SlotIndexes *getSlotIndexes() const { SlotIndexes *getSlotIndexes() const {

View File

@ -542,26 +542,25 @@ void LiveIntervals::extendToIndices(LiveRange &LR,
LRCalc->extend(LR, Indices[i]); LRCalc->extend(LR, Indices[i]);
} }
void LiveIntervals::pruneValue(LiveInterval *LI, SlotIndex Kill, void LiveIntervals::pruneValue(LiveRange &LR, SlotIndex Kill,
SmallVectorImpl<SlotIndex> *EndPoints) { SmallVectorImpl<SlotIndex> *EndPoints) {
LiveQueryResult LRQ = LI->Query(Kill); LiveQueryResult LRQ = LR.Query(Kill);
VNInfo *VNI = LRQ.valueOut(); VNInfo *VNI = LRQ.valueOutOrDead();
if (!VNI) if (!VNI)
return; return;
MachineBasicBlock *KillMBB = Indexes->getMBBFromIndex(Kill); MachineBasicBlock *KillMBB = Indexes->getMBBFromIndex(Kill);
SlotIndex MBBStart, MBBEnd; SlotIndex MBBEnd = Indexes->getMBBEndIdx(KillMBB);
std::tie(MBBStart, MBBEnd) = Indexes->getMBBRange(KillMBB);
// If VNI isn't live out from KillMBB, the value is trivially pruned. // If VNI isn't live out from KillMBB, the value is trivially pruned.
if (LRQ.endPoint() < MBBEnd) { if (LRQ.endPoint() < MBBEnd) {
LI->removeSegment(Kill, LRQ.endPoint()); LR.removeSegment(Kill, LRQ.endPoint());
if (EndPoints) EndPoints->push_back(LRQ.endPoint()); if (EndPoints) EndPoints->push_back(LRQ.endPoint());
return; return;
} }
// VNI is live out of KillMBB. // VNI is live out of KillMBB.
LI->removeSegment(Kill, MBBEnd); LR.removeSegment(Kill, MBBEnd);
if (EndPoints) EndPoints->push_back(MBBEnd); if (EndPoints) EndPoints->push_back(MBBEnd);
// Find all blocks that are reachable from KillMBB without leaving VNI's live // Find all blocks that are reachable from KillMBB without leaving VNI's live
@ -578,8 +577,9 @@ void LiveIntervals::pruneValue(LiveInterval *LI, SlotIndex Kill,
MachineBasicBlock *MBB = *I; MachineBasicBlock *MBB = *I;
// Check if VNI is live in to MBB. // Check if VNI is live in to MBB.
SlotIndex MBBStart, MBBEnd;
std::tie(MBBStart, MBBEnd) = Indexes->getMBBRange(MBB); std::tie(MBBStart, MBBEnd) = Indexes->getMBBRange(MBB);
LiveQueryResult LRQ = LI->Query(MBBStart); LiveQueryResult LRQ = LR.Query(MBBStart);
if (LRQ.valueIn() != VNI) { if (LRQ.valueIn() != VNI) {
// This block isn't part of the VNI segment. Prune the search. // This block isn't part of the VNI segment. Prune the search.
I.skipChildren(); I.skipChildren();
@ -588,20 +588,30 @@ void LiveIntervals::pruneValue(LiveInterval *LI, SlotIndex Kill,
// Prune the search if VNI is killed in MBB. // Prune the search if VNI is killed in MBB.
if (LRQ.endPoint() < MBBEnd) { if (LRQ.endPoint() < MBBEnd) {
LI->removeSegment(MBBStart, LRQ.endPoint()); LR.removeSegment(MBBStart, LRQ.endPoint());
if (EndPoints) EndPoints->push_back(LRQ.endPoint()); if (EndPoints) EndPoints->push_back(LRQ.endPoint());
I.skipChildren(); I.skipChildren();
continue; continue;
} }
// VNI is live through MBB. // VNI is live through MBB.
LI->removeSegment(MBBStart, MBBEnd); LR.removeSegment(MBBStart, MBBEnd);
if (EndPoints) EndPoints->push_back(MBBEnd); if (EndPoints) EndPoints->push_back(MBBEnd);
++I; ++I;
} }
} }
} }
void LiveIntervals::pruneValue(LiveInterval &LI, SlotIndex Kill,
SmallVectorImpl<SlotIndex> *EndPoints) {
pruneValue((LiveRange&)LI, Kill, EndPoints);
for (LiveInterval::subrange_iterator SR = LI.subrange_begin(),
SE = LI.subrange_end(); SR != SE; ++SR) {
pruneValue(*SR, Kill, nullptr);
}
}
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Register allocator hooks. // Register allocator hooks.
// //

View File

@ -1917,7 +1917,7 @@ void JoinVals::pruneValues(JoinVals &Other,
break; break;
case CR_Replace: { case CR_Replace: {
// This value takes precedence over the value in Other.LI. // This value takes precedence over the value in Other.LI.
LIS->pruneValue(&Other.LI, Def, &EndPoints); LIS->pruneValue(Other.LI, Def, &EndPoints);
// Check if we're replacing an IMPLICIT_DEF value. The IMPLICIT_DEF // Check if we're replacing an IMPLICIT_DEF value. The IMPLICIT_DEF
// instructions are only inserted to provide a live-out value for PHI // instructions are only inserted to provide a live-out value for PHI
// predecessors, so the instruction should simply go away once its value // predecessors, so the instruction should simply go away once its value
@ -1951,7 +1951,7 @@ void JoinVals::pruneValues(JoinVals &Other,
// We can no longer trust the value mapping computed by // We can no longer trust the value mapping computed by
// computeAssignment(), the value that was originally copied could have // computeAssignment(), the value that was originally copied could have
// been replaced. // been replaced.
LIS->pruneValue(&LI, Def, &EndPoints); LIS->pruneValue(LI, Def, &EndPoints);
DEBUG(dbgs() << "\t\tpruned all of " << PrintReg(LI.reg) << " at " DEBUG(dbgs() << "\t\tpruned all of " << PrintReg(LI.reg) << " at "
<< Def << ": " << LI << '\n'); << Def << ": " << LI << '\n');
} }