1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00

Rename {First,Last}Use to {First,Last}Instr.

With a 'FirstDef' field right there, it is very confusing that FirstUse
refers to an instruction that may be a def.

llvm-svn: 136739
This commit is contained in:
Jakob Stoklund Olesen 2011-08-02 22:54:14 +00:00
parent c4182308a3
commit 4b62c6ea69
3 changed files with 45 additions and 43 deletions

View File

@ -687,9 +687,9 @@ bool RAGreedy::addSplitConstraints(InterferenceCache::Cursor Intf,
if (BI.LiveIn) { if (BI.LiveIn) {
if (Intf.first() <= Indexes->getMBBStartIdx(BC.Number)) if (Intf.first() <= Indexes->getMBBStartIdx(BC.Number))
BC.Entry = SpillPlacement::MustSpill, ++Ins; BC.Entry = SpillPlacement::MustSpill, ++Ins;
else if (Intf.first() < BI.FirstUse) else if (Intf.first() < BI.FirstInstr)
BC.Entry = SpillPlacement::PrefSpill, ++Ins; BC.Entry = SpillPlacement::PrefSpill, ++Ins;
else if (Intf.first() < BI.LastUse) else if (Intf.first() < BI.LastInstr)
++Ins; ++Ins;
} }
@ -697,9 +697,9 @@ bool RAGreedy::addSplitConstraints(InterferenceCache::Cursor Intf,
if (BI.LiveOut) { if (BI.LiveOut) {
if (Intf.last() >= SA->getLastSplitPoint(BC.Number)) if (Intf.last() >= SA->getLastSplitPoint(BC.Number))
BC.Exit = SpillPlacement::MustSpill, ++Ins; BC.Exit = SpillPlacement::MustSpill, ++Ins;
else if (Intf.last() > BI.LastUse) else if (Intf.last() > BI.LastInstr)
BC.Exit = SpillPlacement::PrefSpill, ++Ins; BC.Exit = SpillPlacement::PrefSpill, ++Ins;
else if (Intf.last() > BI.FirstUse) else if (Intf.last() > BI.FirstInstr)
++Ins; ++Ins;
} }
@ -1216,8 +1216,10 @@ void RAGreedy::calcGapWeights(unsigned PhysReg,
const unsigned NumGaps = Uses.size()-1; const unsigned NumGaps = Uses.size()-1;
// Start and end points for the interference check. // Start and end points for the interference check.
SlotIndex StartIdx = BI.LiveIn ? BI.FirstUse.getBaseIndex() : BI.FirstUse; SlotIndex StartIdx =
SlotIndex StopIdx = BI.LiveOut ? BI.LastUse.getBoundaryIndex() : BI.LastUse; BI.LiveIn ? BI.FirstInstr.getBaseIndex() : BI.FirstInstr;
SlotIndex StopIdx =
BI.LiveOut ? BI.LastInstr.getBoundaryIndex() : BI.LastInstr;
GapWeight.assign(NumGaps, 0.0f); GapWeight.assign(NumGaps, 0.0f);
@ -1227,8 +1229,8 @@ void RAGreedy::calcGapWeights(unsigned PhysReg,
.checkInterference()) .checkInterference())
continue; continue;
// We know that VirtReg is a continuous interval from FirstUse to LastUse, // We know that VirtReg is a continuous interval from FirstInstr to
// so we don't need InterferenceQuery. // LastInstr, so we don't need InterferenceQuery.
// //
// Interference that overlaps an instruction is counted in both gaps // Interference that overlaps an instruction is counted in both gaps
// surrounding the instruction. The exception is interference before // surrounding the instruction. The exception is interference before
@ -1268,8 +1270,8 @@ unsigned RAGreedy::tryLocalSplit(LiveInterval &VirtReg, AllocationOrder &Order,
// while only covering a single block - A phi-def can use undef values from // while only covering a single block - A phi-def can use undef values from
// predecessors, and the block could be a single-block loop. // predecessors, and the block could be a single-block loop.
// We don't bother doing anything clever about such a case, we simply assume // We don't bother doing anything clever about such a case, we simply assume
// that the interval is continuous from FirstUse to LastUse. We should make // that the interval is continuous from FirstInstr to LastInstr. We should
// sure that we don't do anything illegal to such an interval, though. // make sure that we don't do anything illegal to such an interval, though.
const SmallVectorImpl<SlotIndex> &Uses = SA->UseSlots; const SmallVectorImpl<SlotIndex> &Uses = SA->UseSlots;
if (Uses.size() <= 2) if (Uses.size() <= 2)

View File

@ -178,12 +178,12 @@ bool SplitAnalysis::calcLiveBlockInfo() {
return false; return false;
} else { } else {
// This block has uses. Find the first and last uses in the block. // This block has uses. Find the first and last uses in the block.
BI.FirstUse = *UseI; BI.FirstInstr = *UseI;
assert(BI.FirstUse >= Start); assert(BI.FirstInstr >= Start);
do ++UseI; do ++UseI;
while (UseI != UseE && *UseI < Stop); while (UseI != UseE && *UseI < Stop);
BI.LastUse = UseI[-1]; BI.LastInstr = UseI[-1];
assert(BI.LastUse < Stop); assert(BI.LastInstr < Stop);
// LVI is the first live segment overlapping MBB. // LVI is the first live segment overlapping MBB.
BI.LiveIn = LVI->start <= Start; BI.LiveIn = LVI->start <= Start;
@ -191,8 +191,8 @@ bool SplitAnalysis::calcLiveBlockInfo() {
// When not live in, the first use should be a def. // When not live in, the first use should be a def.
if (!BI.LiveIn) { if (!BI.LiveIn) {
assert(LVI->start == LVI->valno->def && "Dangling LiveRange start"); assert(LVI->start == LVI->valno->def && "Dangling LiveRange start");
assert(LVI->start == BI.FirstUse && "First instr should be a def"); assert(LVI->start == BI.FirstInstr && "First instr should be a def");
BI.FirstDef = BI.FirstUse; BI.FirstDef = BI.FirstInstr;
} }
// Look for gaps in the live range. // Look for gaps in the live range.
@ -201,7 +201,7 @@ bool SplitAnalysis::calcLiveBlockInfo() {
SlotIndex LastStop = LVI->end; SlotIndex LastStop = LVI->end;
if (++LVI == LVE || LVI->start >= Stop) { if (++LVI == LVE || LVI->start >= Stop) {
BI.LiveOut = false; BI.LiveOut = false;
BI.LastUse = LastStop; BI.LastInstr = LastStop;
break; break;
} }
@ -213,12 +213,12 @@ bool SplitAnalysis::calcLiveBlockInfo() {
// Push the Live-in part. // Push the Live-in part.
BI.LiveOut = false; BI.LiveOut = false;
UseBlocks.push_back(BI); UseBlocks.push_back(BI);
UseBlocks.back().LastUse = LastStop; UseBlocks.back().LastInstr = LastStop;
// Set up BI for the live-out part. // Set up BI for the live-out part.
BI.LiveIn = false; BI.LiveIn = false;
BI.LiveOut = true; BI.LiveOut = true;
BI.FirstUse = BI.FirstDef = LVI->start; BI.FirstInstr = BI.FirstDef = LVI->start;
} }
// A LiveRange that starts in the middle of the block must be a def. // A LiveRange that starts in the middle of the block must be a def.
@ -1096,7 +1096,7 @@ bool SplitAnalysis::getMultiUseBlocks(BlockPtrSet &Blocks) {
// Add blocks with multiple uses. // Add blocks with multiple uses.
for (unsigned i = 0, e = UseBlocks.size(); i != e; ++i) { for (unsigned i = 0, e = UseBlocks.size(); i != e; ++i) {
const BlockInfo &BI = UseBlocks[i]; const BlockInfo &BI = UseBlocks[i];
if (BI.FirstUse == BI.LastUse) if (BI.FirstInstr == BI.LastInstr)
continue; continue;
Blocks.insert(BI.MBB); Blocks.insert(BI.MBB);
} }
@ -1106,15 +1106,15 @@ bool SplitAnalysis::getMultiUseBlocks(BlockPtrSet &Blocks) {
void SplitEditor::splitSingleBlock(const SplitAnalysis::BlockInfo &BI) { void SplitEditor::splitSingleBlock(const SplitAnalysis::BlockInfo &BI) {
openIntv(); openIntv();
SlotIndex LastSplitPoint = SA.getLastSplitPoint(BI.MBB->getNumber()); SlotIndex LastSplitPoint = SA.getLastSplitPoint(BI.MBB->getNumber());
SlotIndex SegStart = enterIntvBefore(std::min(BI.FirstUse, SlotIndex SegStart = enterIntvBefore(std::min(BI.FirstInstr,
LastSplitPoint)); LastSplitPoint));
if (!BI.LiveOut || BI.LastUse < LastSplitPoint) { if (!BI.LiveOut || BI.LastInstr < LastSplitPoint) {
useIntv(SegStart, leaveIntvAfter(BI.LastUse)); useIntv(SegStart, leaveIntvAfter(BI.LastInstr));
} else { } else {
// The last use is after the last valid split point. // The last use is after the last valid split point.
SlotIndex SegStop = leaveIntvBefore(LastSplitPoint); SlotIndex SegStop = leaveIntvBefore(LastSplitPoint);
useIntv(SegStart, SegStop); useIntv(SegStart, SegStop);
overlapIntv(SegStop, BI.LastUse); overlapIntv(SegStop, BI.LastInstr);
} }
} }
@ -1253,7 +1253,7 @@ void SplitEditor::splitRegInBlock(const SplitAnalysis::BlockInfo &BI,
tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(BI.MBB); tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(BI.MBB);
DEBUG(dbgs() << "BB#" << BI.MBB->getNumber() << " [" << Start << ';' << Stop DEBUG(dbgs() << "BB#" << BI.MBB->getNumber() << " [" << Start << ';' << Stop
<< "), uses " << BI.FirstUse << '-' << BI.LastUse << "), uses " << BI.FirstInstr << '-' << BI.LastInstr
<< ", reg-in " << IntvIn << ", leave before " << LeaveBefore << ", reg-in " << IntvIn << ", leave before " << LeaveBefore
<< (BI.LiveOut ? ", stack-out" : ", killed in block")); << (BI.LiveOut ? ", stack-out" : ", killed in block"));
@ -1261,7 +1261,7 @@ void SplitEditor::splitRegInBlock(const SplitAnalysis::BlockInfo &BI,
assert(BI.LiveIn && "Must be live-in"); assert(BI.LiveIn && "Must be live-in");
assert((!LeaveBefore || LeaveBefore > Start) && "Bad interference"); assert((!LeaveBefore || LeaveBefore > Start) && "Bad interference");
if (!BI.LiveOut && (!LeaveBefore || LeaveBefore >= BI.LastUse)) { if (!BI.LiveOut && (!LeaveBefore || LeaveBefore >= BI.LastInstr)) {
DEBUG(dbgs() << " before interference.\n"); DEBUG(dbgs() << " before interference.\n");
// //
// <<< Interference after kill. // <<< Interference after kill.
@ -1269,13 +1269,13 @@ void SplitEditor::splitRegInBlock(const SplitAnalysis::BlockInfo &BI,
// ========= Use IntvIn everywhere. // ========= Use IntvIn everywhere.
// //
selectIntv(IntvIn); selectIntv(IntvIn);
useIntv(Start, BI.LastUse); useIntv(Start, BI.LastInstr);
return; return;
} }
SlotIndex LSP = SA.getLastSplitPoint(BI.MBB->getNumber()); SlotIndex LSP = SA.getLastSplitPoint(BI.MBB->getNumber());
if (!LeaveBefore || LeaveBefore > BI.LastUse.getBoundaryIndex()) { if (!LeaveBefore || LeaveBefore > BI.LastInstr.getBoundaryIndex()) {
// //
// <<< Possible interference after last use. // <<< Possible interference after last use.
// |---o---o---| Live-out on stack. // |---o---o---| Live-out on stack.
@ -1286,17 +1286,17 @@ void SplitEditor::splitRegInBlock(const SplitAnalysis::BlockInfo &BI,
// ============ Copy to stack after LSP, overlap IntvIn. // ============ Copy to stack after LSP, overlap IntvIn.
// \_____ Stack interval is live-out. // \_____ Stack interval is live-out.
// //
if (BI.LastUse < LSP) { if (BI.LastInstr < LSP) {
DEBUG(dbgs() << ", spill after last use before interference.\n"); DEBUG(dbgs() << ", spill after last use before interference.\n");
selectIntv(IntvIn); selectIntv(IntvIn);
SlotIndex Idx = leaveIntvAfter(BI.LastUse); SlotIndex Idx = leaveIntvAfter(BI.LastInstr);
useIntv(Start, Idx); useIntv(Start, Idx);
assert((!LeaveBefore || Idx <= LeaveBefore) && "Interference"); assert((!LeaveBefore || Idx <= LeaveBefore) && "Interference");
} else { } else {
DEBUG(dbgs() << ", spill before last split point.\n"); DEBUG(dbgs() << ", spill before last split point.\n");
selectIntv(IntvIn); selectIntv(IntvIn);
SlotIndex Idx = leaveIntvBefore(LSP); SlotIndex Idx = leaveIntvBefore(LSP);
overlapIntv(Idx, BI.LastUse); overlapIntv(Idx, BI.LastInstr);
useIntv(Start, Idx); useIntv(Start, Idx);
assert((!LeaveBefore || Idx <= LeaveBefore) && "Interference"); assert((!LeaveBefore || Idx <= LeaveBefore) && "Interference");
} }
@ -1310,13 +1310,13 @@ void SplitEditor::splitRegInBlock(const SplitAnalysis::BlockInfo &BI,
(void)LocalIntv; (void)LocalIntv;
DEBUG(dbgs() << ", creating local interval " << LocalIntv << ".\n"); DEBUG(dbgs() << ", creating local interval " << LocalIntv << ".\n");
if (!BI.LiveOut || BI.LastUse < LSP) { if (!BI.LiveOut || BI.LastInstr < LSP) {
// //
// <<<<<<< Interference overlapping uses. // <<<<<<< Interference overlapping uses.
// |---o---o---| Live-out on stack. // |---o---o---| Live-out on stack.
// =====----____ Leave IntvIn before interference, then spill. // =====----____ Leave IntvIn before interference, then spill.
// //
SlotIndex To = leaveIntvAfter(BI.LastUse); SlotIndex To = leaveIntvAfter(BI.LastInstr);
SlotIndex From = enterIntvBefore(LeaveBefore); SlotIndex From = enterIntvBefore(LeaveBefore);
useIntv(From, To); useIntv(From, To);
selectIntv(IntvIn); selectIntv(IntvIn);
@ -1331,7 +1331,7 @@ void SplitEditor::splitRegInBlock(const SplitAnalysis::BlockInfo &BI,
// \_____ Stack interval is live-out. // \_____ Stack interval is live-out.
// //
SlotIndex To = leaveIntvBefore(LSP); SlotIndex To = leaveIntvBefore(LSP);
overlapIntv(To, BI.LastUse); overlapIntv(To, BI.LastInstr);
SlotIndex From = enterIntvBefore(std::min(To, LeaveBefore)); SlotIndex From = enterIntvBefore(std::min(To, LeaveBefore));
useIntv(From, To); useIntv(From, To);
selectIntv(IntvIn); selectIntv(IntvIn);
@ -1345,7 +1345,7 @@ void SplitEditor::splitRegOutBlock(const SplitAnalysis::BlockInfo &BI,
tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(BI.MBB); tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(BI.MBB);
DEBUG(dbgs() << "BB#" << BI.MBB->getNumber() << " [" << Start << ';' << Stop DEBUG(dbgs() << "BB#" << BI.MBB->getNumber() << " [" << Start << ';' << Stop
<< "), uses " << BI.FirstUse << '-' << BI.LastUse << "), uses " << BI.FirstInstr << '-' << BI.LastInstr
<< ", reg-out " << IntvOut << ", enter after " << EnterAfter << ", reg-out " << IntvOut << ", enter after " << EnterAfter
<< (BI.LiveIn ? ", stack-in" : ", defined in block")); << (BI.LiveIn ? ", stack-in" : ", defined in block"));
@ -1355,7 +1355,7 @@ void SplitEditor::splitRegOutBlock(const SplitAnalysis::BlockInfo &BI,
assert(BI.LiveOut && "Must be live-out"); assert(BI.LiveOut && "Must be live-out");
assert((!EnterAfter || EnterAfter < LSP) && "Bad interference"); assert((!EnterAfter || EnterAfter < LSP) && "Bad interference");
if (!BI.LiveIn && (!EnterAfter || EnterAfter <= BI.FirstUse)) { if (!BI.LiveIn && (!EnterAfter || EnterAfter <= BI.FirstInstr)) {
DEBUG(dbgs() << " after interference.\n"); DEBUG(dbgs() << " after interference.\n");
// //
// >>>> Interference before def. // >>>> Interference before def.
@ -1363,11 +1363,11 @@ void SplitEditor::splitRegOutBlock(const SplitAnalysis::BlockInfo &BI,
// ========= Use IntvOut everywhere. // ========= Use IntvOut everywhere.
// //
selectIntv(IntvOut); selectIntv(IntvOut);
useIntv(BI.FirstUse, Stop); useIntv(BI.FirstInstr, Stop);
return; return;
} }
if (!EnterAfter || EnterAfter < BI.FirstUse.getBaseIndex()) { if (!EnterAfter || EnterAfter < BI.FirstInstr.getBaseIndex()) {
DEBUG(dbgs() << ", reload after interference.\n"); DEBUG(dbgs() << ", reload after interference.\n");
// //
// >>>> Interference before def. // >>>> Interference before def.
@ -1375,7 +1375,7 @@ void SplitEditor::splitRegOutBlock(const SplitAnalysis::BlockInfo &BI,
// ____========= Enter IntvOut before first use. // ____========= Enter IntvOut before first use.
// //
selectIntv(IntvOut); selectIntv(IntvOut);
SlotIndex Idx = enterIntvBefore(std::min(LSP, BI.FirstUse)); SlotIndex Idx = enterIntvBefore(std::min(LSP, BI.FirstInstr));
useIntv(Idx, Stop); useIntv(Idx, Stop);
assert((!EnterAfter || Idx >= EnterAfter) && "Interference"); assert((!EnterAfter || Idx >= EnterAfter) && "Interference");
return; return;
@ -1396,6 +1396,6 @@ void SplitEditor::splitRegOutBlock(const SplitAnalysis::BlockInfo &BI,
assert((!EnterAfter || Idx >= EnterAfter) && "Interference"); assert((!EnterAfter || Idx >= EnterAfter) && "Interference");
openIntv(); openIntv();
SlotIndex From = enterIntvBefore(std::min(Idx, BI.FirstUse)); SlotIndex From = enterIntvBefore(std::min(Idx, BI.FirstInstr));
useIntv(From, Idx); useIntv(From, Idx);
} }

View File

@ -76,8 +76,8 @@ public:
/// ///
struct BlockInfo { struct BlockInfo {
MachineBasicBlock *MBB; MachineBasicBlock *MBB;
SlotIndex FirstUse; ///< First instr using current reg. SlotIndex FirstInstr; ///< First instr accessing current reg.
SlotIndex LastUse; ///< Last instr using current reg. SlotIndex LastInstr; ///< Last instr accessing current reg.
SlotIndex FirstDef; ///< First non-phi valno->def, or SlotIndex(). SlotIndex FirstDef; ///< First non-phi valno->def, or SlotIndex().
bool LiveIn; ///< Current reg is live in. bool LiveIn; ///< Current reg is live in.
bool LiveOut; ///< Current reg is live out. bool LiveOut; ///< Current reg is live out.
@ -85,7 +85,7 @@ public:
/// isOneInstr - Returns true when this BlockInfo describes a single /// isOneInstr - Returns true when this BlockInfo describes a single
/// instruction. /// instruction.
bool isOneInstr() const { bool isOneInstr() const {
return SlotIndex::isSameInstr(FirstUse, LastUse); return SlotIndex::isSameInstr(FirstInstr, LastInstr);
} }
}; };