Skip to content

Commit 02a5354

Browse files
committed
Make the set of fixed (preallocated) intervals be a fixed superset of
unhandled + handled. So unhandled is now including all fixed intervals and fixed intervals never changes when processing a function. llvm-svn: 12462
1 parent a3783a5 commit 02a5354

File tree

1 file changed

+10
-29
lines changed

1 file changed

+10
-29
lines changed

llvm/lib/CodeGen/RegAllocLinearScan.cpp

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ namespace {
135135
void RA::releaseMemory()
136136
{
137137
unhandled_.clear();
138+
fixed_.clear();
138139
active_.clear();
139140
inactive_.clear();
140-
fixed_.clear();
141141
handled_.clear();
142142
}
143143

@@ -171,25 +171,10 @@ void RA::linearScan()
171171
DEBUG(printIntervals("active", active_.begin(), active_.end()));
172172
DEBUG(printIntervals("inactive", inactive_.begin(), inactive_.end()));
173173

174-
while (!unhandled_.empty() || !fixed_.empty()) {
174+
while (!unhandled_.empty()) {
175175
// pick the interval with the earliest start point
176-
IntervalPtrs::value_type cur;
177-
if (fixed_.empty()) {
178-
cur = unhandled_.front();
179-
unhandled_.pop_front();
180-
}
181-
else if (unhandled_.empty()) {
182-
cur = fixed_.front();
183-
fixed_.pop_front();
184-
}
185-
else if (unhandled_.front()->start() < fixed_.front()->start()) {
186-
cur = unhandled_.front();
187-
unhandled_.pop_front();
188-
}
189-
else {
190-
cur = fixed_.front();
191-
fixed_.pop_front();
192-
}
176+
IntervalPtrs::value_type cur = unhandled_.front();
177+
unhandled_.pop_front();
193178

194179
DEBUG(std::cerr << "\n*** CURRENT ***: " << *cur << '\n');
195180

@@ -234,10 +219,9 @@ void RA::initIntervalSets(LiveIntervals::Intervals& li)
234219

235220
for (LiveIntervals::Intervals::iterator i = li.begin(), e = li.end();
236221
i != e; ++i) {
222+
unhandled_.push_back(&*i);
237223
if (MRegisterInfo::isPhysicalRegister(i->reg))
238224
fixed_.push_back(&*i);
239-
else
240-
unhandled_.push_back(&*i);
241225
}
242226
}
243227

@@ -444,7 +428,7 @@ void RA::assignRegOrStackSlotAtInterval(IntervalPtrs::value_type cur)
444428

445429
DEBUG(std::cerr << "\t\trolling back to: " << earliestStart << '\n');
446430
// scan handled in reverse order and undo each one, restoring the
447-
// state of unhandled and fixed
431+
// state of unhandled
448432
while (!handled_.empty()) {
449433
IntervalPtrs::value_type i = handled_.back();
450434
// if this interval starts before t we are done
@@ -456,8 +440,8 @@ void RA::assignRegOrStackSlotAtInterval(IntervalPtrs::value_type cur)
456440
if ((it = find(active_.begin(), active_.end(), i)) != active_.end()) {
457441
active_.erase(it);
458442
if (MRegisterInfo::isPhysicalRegister(i->reg)) {
459-
fixed_.push_front(i);
460443
prt_->delRegUse(i->reg);
444+
unhandled_.push_front(i);
461445
}
462446
else {
463447
prt_->delRegUse(vrm_->getPhys(i->reg));
@@ -479,7 +463,7 @@ void RA::assignRegOrStackSlotAtInterval(IntervalPtrs::value_type cur)
479463
else if ((it = find(inactive_.begin(), inactive_.end(), i)) != inactive_.end()) {
480464
inactive_.erase(it);
481465
if (MRegisterInfo::isPhysicalRegister(i->reg))
482-
fixed_.push_front(i);
466+
unhandled_.push_front(i);
483467
else {
484468
vrm_->clearVirt(i->reg);
485469
if (i->spilled()) {
@@ -496,12 +480,9 @@ void RA::assignRegOrStackSlotAtInterval(IntervalPtrs::value_type cur)
496480
}
497481
}
498482
else {
499-
if (MRegisterInfo::isPhysicalRegister(i->reg))
500-
fixed_.push_front(i);
501-
else {
483+
if (MRegisterInfo::isVirtualRegister(i->reg))
502484
vrm_->clearVirt(i->reg);
503-
unhandled_.push_front(i);
504-
}
485+
unhandled_.push_front(i);
505486
}
506487
}
507488

0 commit comments

Comments
 (0)