mirror of https://github.com/inolen/redream.git
don't crash on empty live intervals
This commit is contained in:
parent
5acc0c6114
commit
7defb9ab45
|
@ -18,7 +18,7 @@ static inline bool RegisterCanStore(const Register &r, ValueType type) {
|
||||||
|
|
||||||
struct LiveIntervalSort {
|
struct LiveIntervalSort {
|
||||||
bool operator()(const Interval *lhs, const Interval *rhs) const {
|
bool operator()(const Interval *lhs, const Interval *rhs) const {
|
||||||
return GetOrdinal(lhs->next->instr()) < GetOrdinal(rhs->next->instr());
|
return !lhs->next || GetOrdinal(lhs->next->instr()) < GetOrdinal(rhs->next->instr());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -75,8 +75,6 @@ void RegisterSet::PopTailInterval() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterSet::InsertInterval(Interval *interval) {
|
void RegisterSet::InsertInterval(Interval *interval) {
|
||||||
CHECK(interval->start && interval->end && interval->next);
|
|
||||||
|
|
||||||
live_[num_live_++] = interval;
|
live_[num_live_++] = interval;
|
||||||
re::mmheap_push(live_, live_ + num_live_, LiveIntervalSort());
|
re::mmheap_push(live_, live_ + num_live_, LiveIntervalSort());
|
||||||
}
|
}
|
||||||
|
@ -186,7 +184,7 @@ void RegisterAllocationPass::ExpireOldIntervals(Instr *instr) {
|
||||||
|
|
||||||
// intervals are sorted by their next use, once one fails to expire or
|
// intervals are sorted by their next use, once one fails to expire or
|
||||||
// advance, they all will
|
// advance, they all will
|
||||||
if (GetOrdinal(interval->next->instr()) >= GetOrdinal(instr)) {
|
if (interval->next && GetOrdinal(interval->next->instr()) >= GetOrdinal(instr)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +193,7 @@ void RegisterAllocationPass::ExpireOldIntervals(Instr *instr) {
|
||||||
|
|
||||||
// if there are more uses, advance the next use and reinsert the interval
|
// if there are more uses, advance the next use and reinsert the interval
|
||||||
// into the correct position
|
// into the correct position
|
||||||
if (interval->next->next()) {
|
if (interval->next && interval->next->next()) {
|
||||||
interval->next = interval->next->next();
|
interval->next = interval->next->next();
|
||||||
set.InsertInterval(interval);
|
set.InsertInterval(interval);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue