mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
avoid unnecessary direct access to LiveInterval::ranges
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190170 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1920156982
commit
b63db85350
@ -194,6 +194,10 @@ namespace llvm {
|
|||||||
ranges.clear();
|
ranges.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t size() const {
|
||||||
|
return ranges.size();
|
||||||
|
}
|
||||||
|
|
||||||
bool hasAtLeastOneValue() const { return !valnos.empty(); }
|
bool hasAtLeastOneValue() const { return !valnos.empty(); }
|
||||||
|
|
||||||
bool containsOneValue() const { return valnos.size() == 1; }
|
bool containsOneValue() const { return valnos.size() == 1; }
|
||||||
@ -439,9 +443,9 @@ namespace llvm {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Ranges::iterator addRangeFrom(LiveRange LR, Ranges::iterator From);
|
iterator addRangeFrom(LiveRange LR, iterator From);
|
||||||
void extendIntervalEndTo(Ranges::iterator I, SlotIndex NewEnd);
|
void extendIntervalEndTo(iterator I, SlotIndex NewEnd);
|
||||||
Ranges::iterator extendIntervalStartTo(Ranges::iterator I, SlotIndex NewStr);
|
iterator extendIntervalStartTo(iterator I, SlotIndex NewStr);
|
||||||
void markValNoForDeletion(VNInfo *V);
|
void markValNoForDeletion(VNInfo *V);
|
||||||
|
|
||||||
LiveInterval& operator=(const LiveInterval& rhs) LLVM_DELETED_FUNCTION;
|
LiveInterval& operator=(const LiveInterval& rhs) LLVM_DELETED_FUNCTION;
|
||||||
|
@ -38,7 +38,7 @@ LiveInterval::iterator LiveInterval::find(SlotIndex Pos) {
|
|||||||
if (empty() || Pos >= endIndex())
|
if (empty() || Pos >= endIndex())
|
||||||
return end();
|
return end();
|
||||||
iterator I = begin();
|
iterator I = begin();
|
||||||
size_t Len = ranges.size();
|
size_t Len = size();
|
||||||
do {
|
do {
|
||||||
size_t Mid = Len >> 1;
|
size_t Mid = Len >> 1;
|
||||||
if (Pos < I[Mid].end)
|
if (Pos < I[Mid].end)
|
||||||
@ -108,13 +108,13 @@ bool LiveInterval::overlapsFrom(const LiveInterval& other,
|
|||||||
|
|
||||||
if (i->start < j->start) {
|
if (i->start < j->start) {
|
||||||
i = std::upper_bound(i, ie, j->start);
|
i = std::upper_bound(i, ie, j->start);
|
||||||
if (i != ranges.begin()) --i;
|
if (i != begin()) --i;
|
||||||
} else if (j->start < i->start) {
|
} else if (j->start < i->start) {
|
||||||
++StartPos;
|
++StartPos;
|
||||||
if (StartPos != other.end() && StartPos->start <= i->start) {
|
if (StartPos != other.end() && StartPos->start <= i->start) {
|
||||||
assert(StartPos < other.end() && i < end());
|
assert(StartPos < other.end() && i < end());
|
||||||
j = std::upper_bound(j, je, i->start);
|
j = std::upper_bound(j, je, i->start);
|
||||||
if (j != other.ranges.begin()) --j;
|
if (j != other.begin()) --j;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
@ -219,13 +219,13 @@ void LiveInterval::RenumberValues() {
|
|||||||
/// specified by I to end at the specified endpoint. To do this, we should
|
/// specified by I to end at the specified endpoint. To do this, we should
|
||||||
/// merge and eliminate all ranges that this will overlap with. The iterator is
|
/// merge and eliminate all ranges that this will overlap with. The iterator is
|
||||||
/// not invalidated.
|
/// not invalidated.
|
||||||
void LiveInterval::extendIntervalEndTo(Ranges::iterator I, SlotIndex NewEnd) {
|
void LiveInterval::extendIntervalEndTo(iterator I, SlotIndex NewEnd) {
|
||||||
assert(I != ranges.end() && "Not a valid interval!");
|
assert(I != end() && "Not a valid interval!");
|
||||||
VNInfo *ValNo = I->valno;
|
VNInfo *ValNo = I->valno;
|
||||||
|
|
||||||
// Search for the first interval that we can't merge with.
|
// Search for the first interval that we can't merge with.
|
||||||
Ranges::iterator MergeTo = llvm::next(I);
|
iterator MergeTo = llvm::next(I);
|
||||||
for (; MergeTo != ranges.end() && NewEnd >= MergeTo->end; ++MergeTo) {
|
for (; MergeTo != end() && NewEnd >= MergeTo->end; ++MergeTo) {
|
||||||
assert(MergeTo->valno == ValNo && "Cannot merge with differing values!");
|
assert(MergeTo->valno == ValNo && "Cannot merge with differing values!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ void LiveInterval::extendIntervalEndTo(Ranges::iterator I, SlotIndex NewEnd) {
|
|||||||
|
|
||||||
// If the newly formed range now touches the range after it and if they have
|
// If the newly formed range now touches the range after it and if they have
|
||||||
// the same value number, merge the two ranges into one range.
|
// the same value number, merge the two ranges into one range.
|
||||||
if (MergeTo != ranges.end() && MergeTo->start <= I->end &&
|
if (MergeTo != end() && MergeTo->start <= I->end &&
|
||||||
MergeTo->valno == ValNo) {
|
MergeTo->valno == ValNo) {
|
||||||
I->end = MergeTo->end;
|
I->end = MergeTo->end;
|
||||||
++MergeTo;
|
++MergeTo;
|
||||||
@ -248,15 +248,15 @@ void LiveInterval::extendIntervalEndTo(Ranges::iterator I, SlotIndex NewEnd) {
|
|||||||
/// extendIntervalStartTo - This method is used when we want to extend the range
|
/// extendIntervalStartTo - This method is used when we want to extend the range
|
||||||
/// specified by I to start at the specified endpoint. To do this, we should
|
/// specified by I to start at the specified endpoint. To do this, we should
|
||||||
/// merge and eliminate all ranges that this will overlap with.
|
/// merge and eliminate all ranges that this will overlap with.
|
||||||
LiveInterval::Ranges::iterator
|
LiveInterval::iterator
|
||||||
LiveInterval::extendIntervalStartTo(Ranges::iterator I, SlotIndex NewStart) {
|
LiveInterval::extendIntervalStartTo(iterator I, SlotIndex NewStart) {
|
||||||
assert(I != ranges.end() && "Not a valid interval!");
|
assert(I != end() && "Not a valid interval!");
|
||||||
VNInfo *ValNo = I->valno;
|
VNInfo *ValNo = I->valno;
|
||||||
|
|
||||||
// Search for the first interval that we can't merge with.
|
// Search for the first interval that we can't merge with.
|
||||||
Ranges::iterator MergeTo = I;
|
iterator MergeTo = I;
|
||||||
do {
|
do {
|
||||||
if (MergeTo == ranges.begin()) {
|
if (MergeTo == begin()) {
|
||||||
I->start = NewStart;
|
I->start = NewStart;
|
||||||
ranges.erase(MergeTo, I);
|
ranges.erase(MergeTo, I);
|
||||||
return I;
|
return I;
|
||||||
@ -283,11 +283,11 @@ LiveInterval::extendIntervalStartTo(Ranges::iterator I, SlotIndex NewStart) {
|
|||||||
LiveInterval::iterator
|
LiveInterval::iterator
|
||||||
LiveInterval::addRangeFrom(LiveRange LR, iterator From) {
|
LiveInterval::addRangeFrom(LiveRange LR, iterator From) {
|
||||||
SlotIndex Start = LR.start, End = LR.end;
|
SlotIndex Start = LR.start, End = LR.end;
|
||||||
iterator it = std::upper_bound(From, ranges.end(), Start);
|
iterator it = std::upper_bound(From, end(), Start);
|
||||||
|
|
||||||
// If the inserted interval starts in the middle or right at the end of
|
// If the inserted interval starts in the middle or right at the end of
|
||||||
// another interval, just extend that interval to contain the range of LR.
|
// another interval, just extend that interval to contain the range of LR.
|
||||||
if (it != ranges.begin()) {
|
if (it != begin()) {
|
||||||
iterator B = prior(it);
|
iterator B = prior(it);
|
||||||
if (LR.valno == B->valno) {
|
if (LR.valno == B->valno) {
|
||||||
if (B->start <= Start && B->end >= Start) {
|
if (B->start <= Start && B->end >= Start) {
|
||||||
@ -305,7 +305,7 @@ LiveInterval::addRangeFrom(LiveRange LR, iterator From) {
|
|||||||
|
|
||||||
// Otherwise, if this range ends in the middle of, or right next to, another
|
// Otherwise, if this range ends in the middle of, or right next to, another
|
||||||
// interval, merge it into that interval.
|
// interval, merge it into that interval.
|
||||||
if (it != ranges.end()) {
|
if (it != end()) {
|
||||||
if (LR.valno == it->valno) {
|
if (LR.valno == it->valno) {
|
||||||
if (it->start <= End) {
|
if (it->start <= End) {
|
||||||
it = extendIntervalStartTo(it, Start);
|
it = extendIntervalStartTo(it, Start);
|
||||||
@ -351,8 +351,8 @@ VNInfo *LiveInterval::extendInBlock(SlotIndex StartIdx, SlotIndex Kill) {
|
|||||||
void LiveInterval::removeRange(SlotIndex Start, SlotIndex End,
|
void LiveInterval::removeRange(SlotIndex Start, SlotIndex End,
|
||||||
bool RemoveDeadValNo) {
|
bool RemoveDeadValNo) {
|
||||||
// Find the LiveRange containing this span.
|
// Find the LiveRange containing this span.
|
||||||
Ranges::iterator I = find(Start);
|
iterator I = find(Start);
|
||||||
assert(I != ranges.end() && "Range is not in interval!");
|
assert(I != end() && "Range is not in interval!");
|
||||||
assert(I->containsRange(Start, End) && "Range is not entirely in interval!");
|
assert(I->containsRange(Start, End) && "Range is not entirely in interval!");
|
||||||
|
|
||||||
// If the span we are removing is at the start of the LiveRange, adjust it.
|
// If the span we are removing is at the start of the LiveRange, adjust it.
|
||||||
@ -398,8 +398,8 @@ void LiveInterval::removeRange(SlotIndex Start, SlotIndex End,
|
|||||||
/// Also remove the value# from value# list.
|
/// Also remove the value# from value# list.
|
||||||
void LiveInterval::removeValNo(VNInfo *ValNo) {
|
void LiveInterval::removeValNo(VNInfo *ValNo) {
|
||||||
if (empty()) return;
|
if (empty()) return;
|
||||||
Ranges::iterator I = ranges.end();
|
iterator I = end();
|
||||||
Ranges::iterator E = ranges.begin();
|
iterator E = begin();
|
||||||
do {
|
do {
|
||||||
--I;
|
--I;
|
||||||
if (I->valno == ValNo)
|
if (I->valno == ValNo)
|
||||||
@ -597,8 +597,7 @@ void LiveInterval::print(raw_ostream &OS) const {
|
|||||||
if (empty())
|
if (empty())
|
||||||
OS << "EMPTY";
|
OS << "EMPTY";
|
||||||
else {
|
else {
|
||||||
for (LiveInterval::Ranges::const_iterator I = ranges.begin(),
|
for (const_iterator I = begin(), E = end(); I != E; ++I) {
|
||||||
E = ranges.end(); I != E; ++I) {
|
|
||||||
OS << *I;
|
OS << *I;
|
||||||
assert(I->valno == getValNumInfo(I->valno->id) && "Bad VNInfo");
|
assert(I->valno == getValNumInfo(I->valno->id) && "Bad VNInfo");
|
||||||
}
|
}
|
||||||
@ -790,7 +789,7 @@ void LiveRangeUpdater::add(LiveRange Seg) {
|
|||||||
// Finally, append to LI or Spills.
|
// Finally, append to LI or Spills.
|
||||||
if (WriteI == E) {
|
if (WriteI == E) {
|
||||||
LI->ranges.push_back(Seg);
|
LI->ranges.push_back(Seg);
|
||||||
WriteI = ReadI = LI->ranges.end();
|
WriteI = ReadI = LI->end();
|
||||||
} else
|
} else
|
||||||
Spills.push_back(Seg);
|
Spills.push_back(Seg);
|
||||||
}
|
}
|
||||||
@ -842,7 +841,7 @@ void LiveRangeUpdater::flush() {
|
|||||||
size_t WritePos = WriteI - LI->begin();
|
size_t WritePos = WriteI - LI->begin();
|
||||||
LI->ranges.insert(ReadI, Spills.size() - GapSize, LiveRange());
|
LI->ranges.insert(ReadI, Spills.size() - GapSize, LiveRange());
|
||||||
// This also invalidated ReadI, but it is recomputed below.
|
// This also invalidated ReadI, but it is recomputed below.
|
||||||
WriteI = LI->ranges.begin() + WritePos;
|
WriteI = LI->begin() + WritePos;
|
||||||
} else {
|
} else {
|
||||||
// Shrink the gap if necessary.
|
// Shrink the gap if necessary.
|
||||||
LI->ranges.erase(WriteI + Spills.size(), ReadI);
|
LI->ranges.erase(WriteI + Spills.size(), ReadI);
|
||||||
|
@ -527,11 +527,11 @@ bool RegisterCoalescer::hasOtherReachingDefs(LiveInterval &IntA,
|
|||||||
for (LiveInterval::iterator AI = IntA.begin(), AE = IntA.end();
|
for (LiveInterval::iterator AI = IntA.begin(), AE = IntA.end();
|
||||||
AI != AE; ++AI) {
|
AI != AE; ++AI) {
|
||||||
if (AI->valno != AValNo) continue;
|
if (AI->valno != AValNo) continue;
|
||||||
LiveInterval::Ranges::iterator BI =
|
LiveInterval::iterator BI =
|
||||||
std::upper_bound(IntB.ranges.begin(), IntB.ranges.end(), AI->start);
|
std::upper_bound(IntB.begin(), IntB.end(), AI->start);
|
||||||
if (BI != IntB.ranges.begin())
|
if (BI != IntB.begin())
|
||||||
--BI;
|
--BI;
|
||||||
for (; BI != IntB.ranges.end() && AI->end >= BI->start; ++BI) {
|
for (; BI != IntB.end() && AI->end >= BI->start; ++BI) {
|
||||||
if (BI->valno == BValNo)
|
if (BI->valno == BValNo)
|
||||||
continue;
|
continue;
|
||||||
if (BI->start <= AI->start && BI->end > AI->start)
|
if (BI->start <= AI->start && BI->end > AI->start)
|
||||||
@ -1089,8 +1089,8 @@ bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// When possible, let DstReg be the larger interval.
|
// When possible, let DstReg be the larger interval.
|
||||||
if (!CP.isPartial() && LIS->getInterval(CP.getSrcReg()).ranges.size() >
|
if (!CP.isPartial() && LIS->getInterval(CP.getSrcReg()).size() >
|
||||||
LIS->getInterval(CP.getDstReg()).ranges.size())
|
LIS->getInterval(CP.getDstReg()).size())
|
||||||
CP.flip();
|
CP.flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ bool StrongPHIElimination::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
LiveInterval &DestLI = LI->getInterval(DestReg);
|
LiveInterval &DestLI = LI->getInterval(DestReg);
|
||||||
LiveInterval &NewLI = LI->getInterval(NewReg);
|
LiveInterval &NewLI = LI->getInterval(NewReg);
|
||||||
|
|
||||||
assert(DestLI.ranges.size() == 1
|
assert(DestLI.size() == 1
|
||||||
&& "PHI destination copy's live interval should be a single live "
|
&& "PHI destination copy's live interval should be a single live "
|
||||||
"range from the beginning of the BB to the copy instruction.");
|
"range from the beginning of the BB to the copy instruction.");
|
||||||
LiveRange *DestLR = DestLI.begin();
|
LiveRange *DestLR = DestLI.begin();
|
||||||
|
Loading…
Reference in New Issue
Block a user