summaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-05-12 19:07:46 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-05-12 19:07:46 +0000
commit3b6d56cab3dde20699d862fbd859bcb4ea4ed16e (patch)
treecf8a311cec99c85882b5ca4d6653bae667582eed /lib/CodeGen
parent0bbac9ffd17280baa780e248911d4cd05870536b (diff)
downloadllvm-3b6d56cab3dde20699d862fbd859bcb4ea4ed16e.tar.gz
llvm-3b6d56cab3dde20699d862fbd859bcb4ea4ed16e.tar.bz2
llvm-3b6d56cab3dde20699d862fbd859bcb4ea4ed16e.tar.xz
If the register allocator cannot find a register to spill, try the aliases. If
that still fails (because all the register spill weights are inf), just grab one. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28262 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/RegAllocLinearScan.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/CodeGen/RegAllocLinearScan.cpp b/lib/CodeGen/RegAllocLinearScan.cpp
index 90b8fe2714..0fb8f3d136 100644
--- a/lib/CodeGen/RegAllocLinearScan.cpp
+++ b/lib/CodeGen/RegAllocLinearScan.cpp
@@ -551,15 +551,32 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
}
// If we didn't find a register that is spillable, try aliases?
+ if (!minReg) {
+ for (TargetRegisterClass::iterator i = RC->allocation_order_begin(*mf_),
+ e = RC->allocation_order_end(*mf_); i != e; ++i) {
+ unsigned reg = *i;
+ // No need to worry about if the alias register size < regsize of RC.
+ // We are going to spill all registers that alias it anyway.
+ for (const unsigned* as = mri_->getAliasSet(reg); *as; ++as) {
+ if (minWeight > SpillWeights[*as]) {
+ minWeight = SpillWeights[*as];
+ minReg = *as;
+ }
+ }
+ }
+
+ // All registers must have inf weight. Just grab one!
+ if (!minReg)
+ minReg = *RC->allocation_order_begin(*mf_);
+ }
-// FIXME: assert(minReg && "Didn't find any reg!");
DEBUG(std::cerr << "\t\tregister with min weight: "
<< mri_->getName(minReg) << " (" << minWeight << ")\n");
// if the current has the minimum weight, we need to spill it and
// add any added intervals back to unhandled, and restart
// linearscan.
- if (cur->weight <= minWeight) {
+ if (cur->weight != float(HUGE_VAL) && cur->weight <= minWeight) {
DEBUG(std::cerr << "\t\t\tspilling(c): " << *cur << '\n';);
int slot = vrm_->assignVirt2StackSlot(cur->reg);
std::vector<LiveInterval*> added =