[llvm-commits] [llvm] r128821 - in /llvm/trunk: include/llvm/CodeGen/SlotIndexes.h lib/CodeGen/RegAllocGreedy.cpp lib/CodeGen/SplitKit.cpp lib/CodeGen/SplitKit.h
Jakob Stoklund Olesen
stoklund at 2pi.dk
Mon Apr 4 08:32:15 PDT 2011
Author: stoklund
Date: Mon Apr 4 10:32:15 2011
New Revision: 128821
URL: http://llvm.org/viewvc/llvm-project?rev=128821&view=rev
Log:
Stop caching basic block index ranges now that SlotIndexes can keep up.
Modified:
llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
llvm/trunk/lib/CodeGen/SplitKit.cpp
llvm/trunk/lib/CodeGen/SplitKit.h
Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=128821&r1=128820&r2=128821&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Mon Apr 4 10:32:15 2011
@@ -518,11 +518,21 @@
return getMBBRange(MBB->getNumber());
}
+ /// Returns the first index in the given basic block number.
+ SlotIndex getMBBStartIdx(unsigned Num) const {
+ return getMBBRange(Num).first;
+ }
+
/// Returns the first index in the given basic block.
SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const {
return getMBBRange(mbb).first;
}
+ /// Returns the last index in the given basic block number.
+ SlotIndex getMBBEndIdx(unsigned Num) const {
+ return getMBBRange(Num).second;
+ }
+
/// Returns the last index in the given basic block.
SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const {
return getMBBRange(mbb).second;
Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=128821&r1=128820&r2=128821&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Mon Apr 4 10:32:15 2011
@@ -433,7 +433,7 @@
// Interference for the live-in value.
if (BI.LiveIn) {
- if (Intf.first() <= BI.Start)
+ if (Intf.first() <= Indexes->getMBBStartIdx(BC.Number))
BC.Entry = SpillPlacement::MustSpill, Ins += BI.Uses;
else if (!BI.Uses)
BC.Entry = SpillPlacement::PrefSpill;
@@ -525,17 +525,19 @@
if (!BI.LiveOut || !RegOut)
continue;
+ SlotIndex Start, Stop;
+ tie(Start, Stop) = Indexes->getMBBRange(BI.MBB);
Intf.moveToBlock(BI.MBB->getNumber());
DEBUG(dbgs() << "BB#" << BI.MBB->getNumber() << " -> EB#"
<< Bundles->getBundle(BI.MBB->getNumber(), 1)
- << " [" << BI.Start << ';' << BI.LastSplitPoint << '-'
- << BI.Stop << ") intf [" << Intf.first() << ';' << Intf.last()
+ << " [" << Start << ';' << BI.LastSplitPoint << '-'
+ << Stop << ") intf [" << Intf.first() << ';' << Intf.last()
<< ')');
// The interference interval should either be invalid or overlap MBB.
- assert((!Intf.hasInterference() || Intf.first() < BI.Stop)
+ assert((!Intf.hasInterference() || Intf.first() < Stop)
&& "Bad interference");
- assert((!Intf.hasInterference() || Intf.last() > BI.Start)
+ assert((!Intf.hasInterference() || Intf.last() > Start)
&& "Bad interference");
// Check interference leaving the block.
@@ -553,14 +555,14 @@
}
if (!BI.LiveThrough) {
DEBUG(dbgs() << ", not live-through.\n");
- SE->useIntv(SE->enterIntvBefore(BI.Def), BI.Stop);
+ SE->useIntv(SE->enterIntvBefore(BI.Def), Stop);
continue;
}
if (!RegIn) {
// Block is live-through, but entry bundle is on the stack.
// Reload just before the first use.
DEBUG(dbgs() << ", not live-in, enter before first use.\n");
- SE->useIntv(SE->enterIntvBefore(BI.FirstUse), BI.Stop);
+ SE->useIntv(SE->enterIntvBefore(BI.FirstUse), Stop);
continue;
}
DEBUG(dbgs() << ", live-through.\n");
@@ -573,7 +575,7 @@
if (!BI.LiveThrough && Intf.last() <= BI.Def) {
// The interference doesn't reach the outgoing segment.
DEBUG(dbgs() << " doesn't affect def from " << BI.Def << '\n');
- SE->useIntv(BI.Def, BI.Stop);
+ SE->useIntv(BI.Def, Stop);
continue;
}
@@ -601,7 +603,7 @@
SlotIndex SegStart = SE->enterIntvBefore(Use);
assert(SegStart >= Intf.last() && "Couldn't avoid interference");
assert(SegStart < BI.LastSplitPoint && "Impossible split point");
- SE->useIntv(SegStart, BI.Stop);
+ SE->useIntv(SegStart, Stop);
continue;
}
}
@@ -623,10 +625,12 @@
continue;
// We have an incoming register. Check for interference.
+ SlotIndex Start, Stop;
+ tie(Start, Stop) = Indexes->getMBBRange(BI.MBB);
Intf.moveToBlock(BI.MBB->getNumber());
DEBUG(dbgs() << "EB#" << Bundles->getBundle(BI.MBB->getNumber(), 0)
- << " -> BB#" << BI.MBB->getNumber() << " [" << BI.Start << ';'
- << BI.LastSplitPoint << '-' << BI.Stop << ')');
+ << " -> BB#" << BI.MBB->getNumber() << " [" << Start << ';'
+ << BI.LastSplitPoint << '-' << Stop << ')');
// Check interference entering the block.
if (!Intf.hasInterference()) {
@@ -637,7 +641,7 @@
// Block is live-through without interference.
if (RegOut) {
DEBUG(dbgs() << ", no uses, live-through.\n");
- SE->useIntv(BI.Start, BI.Stop);
+ SE->useIntv(Start, Stop);
} else {
DEBUG(dbgs() << ", no uses, stack-out.\n");
SE->leaveIntvAtTop(*BI.MBB);
@@ -646,7 +650,7 @@
}
if (!BI.LiveThrough) {
DEBUG(dbgs() << ", killed in block.\n");
- SE->useIntv(BI.Start, SE->leaveIntvAfter(BI.Kill));
+ SE->useIntv(Start, SE->leaveIntvAfter(BI.Kill));
continue;
}
if (!RegOut) {
@@ -654,7 +658,7 @@
// Spill immediately after the last use.
if (BI.LastUse < BI.LastSplitPoint) {
DEBUG(dbgs() << ", uses, stack-out.\n");
- SE->useIntv(BI.Start, SE->leaveIntvAfter(BI.LastUse));
+ SE->useIntv(Start, SE->leaveIntvAfter(BI.LastUse));
continue;
}
// The last use is after the last split point, it is probably an
@@ -662,7 +666,7 @@
DEBUG(dbgs() << ", uses at " << BI.LastUse << " after split point "
<< BI.LastSplitPoint << ", stack-out.\n");
SlotIndex SegEnd = SE->leaveIntvBefore(BI.LastSplitPoint);
- SE->useIntv(BI.Start, SegEnd);
+ SE->useIntv(Start, SegEnd);
// Run a double interval from the split to the last use.
// This makes it possible to spill the complement without affecting the
// indirect branch.
@@ -671,7 +675,7 @@
}
// Register is live-through.
DEBUG(dbgs() << ", uses, live-through.\n");
- SE->useIntv(BI.Start, BI.Stop);
+ SE->useIntv(Start, Stop);
continue;
}
@@ -681,7 +685,7 @@
if (!BI.LiveThrough && Intf.first() >= BI.Kill) {
// The interference doesn't reach the outgoing segment.
DEBUG(dbgs() << " doesn't affect kill at " << BI.Kill << '\n');
- SE->useIntv(BI.Start, BI.Kill);
+ SE->useIntv(Start, BI.Kill);
continue;
}
@@ -703,7 +707,7 @@
DEBUG(dbgs() << ", free use at " << *UI << ".\n");
SlotIndex SegEnd = SE->leaveIntvAfter(Use);
assert(SegEnd <= Intf.first() && "Couldn't avoid interference");
- SE->useIntv(BI.Start, SegEnd);
+ SE->useIntv(Start, SegEnd);
continue;
}
Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=128821&r1=128820&r2=128821&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SplitKit.cpp (original)
+++ llvm/trunk/lib/CodeGen/SplitKit.cpp Mon Apr 4 10:32:15 2011
@@ -118,7 +118,8 @@
for (;;) {
BlockInfo BI;
BI.MBB = MFI;
- tie(BI.Start, BI.Stop) = LIS.getSlotIndexes()->getMBBRange(BI.MBB);
+ SlotIndex Start, Stop;
+ tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(BI.MBB);
// The last split point is the latest possible insertion point that dominates
// all successor blocks. If interference reaches LastSplitPoint, it is not
@@ -126,12 +127,12 @@
// outgoing bundle.
MachineBasicBlock::iterator LSP = LIS.getLastSplitPoint(*CurLI, BI.MBB);
if (LSP == BI.MBB->end())
- BI.LastSplitPoint = BI.Stop;
+ BI.LastSplitPoint = Stop;
else
BI.LastSplitPoint = LIS.getInstructionIndex(LSP);
// LVI is the first live segment overlapping MBB.
- BI.LiveIn = LVI->start <= BI.Start;
+ BI.LiveIn = LVI->start <= Start;
if (!BI.LiveIn)
BI.Def = LVI->start;
@@ -139,19 +140,19 @@
BI.Uses = hasUses(MFI);
if (BI.Uses && UseI != UseE) {
BI.FirstUse = *UseI;
- assert(BI.FirstUse >= BI.Start);
+ assert(BI.FirstUse >= Start);
do ++UseI;
- while (UseI != UseE && *UseI < BI.Stop);
+ while (UseI != UseE && *UseI < Stop);
BI.LastUse = UseI[-1];
- assert(BI.LastUse < BI.Stop);
+ assert(BI.LastUse < Stop);
}
// Look for gaps in the live range.
bool hasGap = false;
BI.LiveOut = true;
- while (LVI->end < BI.Stop) {
+ while (LVI->end < Stop) {
SlotIndex LastStop = LVI->end;
- if (++LVI == LVE || LVI->start >= BI.Stop) {
+ if (++LVI == LVE || LVI->start >= Stop) {
BI.Kill = LastStop;
BI.LiveOut = false;
break;
@@ -177,11 +178,11 @@
break;
// Live segment ends exactly at Stop. Move to the next segment.
- if (LVI->end == BI.Stop && ++LVI == LVE)
+ if (LVI->end == Stop && ++LVI == LVE)
break;
// Pick the next basic block.
- if (LVI->start < BI.Stop)
+ if (LVI->start < Stop)
++MFI;
else
MFI = LIS.getMBBFromIndex(LVI->start);
Modified: llvm/trunk/lib/CodeGen/SplitKit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=128821&r1=128820&r2=128821&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SplitKit.h (original)
+++ llvm/trunk/lib/CodeGen/SplitKit.h Mon Apr 4 10:32:15 2011
@@ -73,8 +73,6 @@
///
struct BlockInfo {
MachineBasicBlock *MBB;
- SlotIndex Start; ///< Beginining of block.
- SlotIndex Stop; ///< End of block.
SlotIndex FirstUse; ///< First instr using current reg.
SlotIndex LastUse; ///< Last instr using current reg.
SlotIndex Kill; ///< Interval end point inside block.
More information about the llvm-commits
mailing list