aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/RegAllocLinearScan.cpp
diff options
context:
space:
mode:
authorAlkis Evlogimenos <alkis@evlogimenos.com>2004-07-25 08:10:33 +0000
committerAlkis Evlogimenos <alkis@evlogimenos.com>2004-07-25 08:10:33 +0000
commit5a0a1c2cba48c24a81fb4f786fb25dccfcf0e335 (patch)
tree1bd2f778ff15f36b8ddf7c50e84f4ccab632c379 /lib/CodeGen/RegAllocLinearScan.cpp
parenta9e2f3d0ab721d6a46dc3a6962d834b3e1c51494 (diff)
Add some comments to the backtracking code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15200 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegAllocLinearScan.cpp')
-rw-r--r--lib/CodeGen/RegAllocLinearScan.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/CodeGen/RegAllocLinearScan.cpp b/lib/CodeGen/RegAllocLinearScan.cpp
index 694be5f7f1..4c44d9201c 100644
--- a/lib/CodeGen/RegAllocLinearScan.cpp
+++ b/lib/CodeGen/RegAllocLinearScan.cpp
@@ -403,13 +403,24 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
assert(MRegisterInfo::isPhysicalRegister(minReg) &&
"did not choose a register to spill?");
std::vector<bool> toSpill(mri_->getNumRegs(), false);
+ // we are going to spill minReg and all its aliases
toSpill[minReg] = true;
for (const unsigned* as = mri_->getAliasSet(minReg); *as; ++as)
toSpill[*as] = true;
+
+ // the earliest start of a spilled interval indicates up to where
+ // in handled we need to roll back
unsigned earliestStart = cur->start();
+ // set of spilled vregs (used later to rollback properly)
std::set<unsigned> spilled;
+ // spill live intervals of virtual regs mapped to the physical
+ // register we want to clear (and its aliases). we only spill
+ // those that overlap with the current interval as the rest do not
+ // affect its allocation. we also keep track of the earliest start
+ // of all spilled live intervals since this will mark our rollback
+ // point
for (IntervalPtrs::iterator
i = active_.begin(); i != active_.end(); ++i) {
unsigned reg = (*i)->reg;
@@ -442,8 +453,9 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
}
DEBUG(std::cerr << "\t\trolling back to: " << earliestStart << '\n');
- // scan handled in reverse order and undo each one, restoring the
- // state of unhandled
+ // scan handled in reverse order up to the earliaset start of a
+ // spilled live interval and undo each one, restoring the state of
+ // unhandled
while (!handled_.empty()) {
LiveInterval* i = handled_.back();
// if this interval starts before t we are done
@@ -451,6 +463,9 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
break;
DEBUG(std::cerr << "\t\t\tundo changes for: " << *i << '\n');
handled_.pop_back();
+ // when undoing a live interval allocation we must know if it
+ // is active or inactive to properly update the PhysRegTracker
+ // and the VirtRegMap
IntervalPtrs::iterator it;
if ((it = find(active_.begin(), active_.end(), i)) != active_.end()) {
active_.erase(it);