aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/RegAllocLinearScan.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-06-06 07:54:39 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-06-06 07:54:39 +0000
commitba221ca2410097537bad9d3a346ae9eb8e332e7c (patch)
tree86f5376db5e101937f1a2fd99cce0e2c49f3a27b /lib/CodeGen/RegAllocLinearScan.cpp
parenta460a3a10d090ef0bb14d033f3ba3592793f635b (diff)
downloadexternal_llvm-ba221ca2410097537bad9d3a346ae9eb8e332e7c.zip
external_llvm-ba221ca2410097537bad9d3a346ae9eb8e332e7c.tar.gz
external_llvm-ba221ca2410097537bad9d3a346ae9eb8e332e7c.tar.bz2
Refine stack slot interval weight computation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52040 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegAllocLinearScan.cpp')
-rw-r--r--lib/CodeGen/RegAllocLinearScan.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/CodeGen/RegAllocLinearScan.cpp b/lib/CodeGen/RegAllocLinearScan.cpp
index 8bfa868..d29f6da 100644
--- a/lib/CodeGen/RegAllocLinearScan.cpp
+++ b/lib/CodeGen/RegAllocLinearScan.cpp
@@ -515,11 +515,14 @@ static void RevertVectorIteratorsTo(RALinScan::IntervalPtrs &V, unsigned Point){
/// addStackInterval - Create a LiveInterval for stack if the specified live
/// interval has been spilled.
static void addStackInterval(LiveInterval *cur, LiveStacks *ls_,
- LiveIntervals *li_, VirtRegMap &vrm_) {
+ LiveIntervals *li_, float &Weight,
+ VirtRegMap &vrm_) {
int SS = vrm_.getStackSlot(cur->reg);
if (SS == VirtRegMap::NO_STACK_SLOT)
return;
LiveInterval &SI = ls_->getOrCreateInterval(SS);
+ SI.weight += Weight;
+
VNInfo *VNI;
if (SI.getNumValNums())
VNI = SI.getValNumInfo(0);
@@ -529,7 +532,6 @@ static void addStackInterval(LiveInterval *cur, LiveStacks *ls_,
LiveInterval &RI = li_->getInterval(cur->reg);
// FIXME: This may be overly conservative.
SI.MergeRangesInAsValue(RI, VNI);
- SI.weight += RI.weight;
}
/// assignRegOrStackSlotAtInterval - assign a register if one is available, or
@@ -743,9 +745,10 @@ void RALinScan::assignRegOrStackSlotAtInterval(LiveInterval* cur)
// linearscan.
if (cur->weight != HUGE_VALF && cur->weight <= minWeight) {
DOUT << "\t\t\tspilling(c): " << *cur << '\n';
+ float SSWeight;
std::vector<LiveInterval*> added =
- li_->addIntervalsForSpills(*cur, loopInfo, *vrm_);
- addStackInterval(cur, ls_, li_, *vrm_);
+ li_->addIntervalsForSpills(*cur, loopInfo, *vrm_, SSWeight);
+ addStackInterval(cur, ls_, li_, SSWeight, *vrm_);
if (added.empty())
return; // Early exit if all spills were folded.
@@ -796,9 +799,10 @@ void RALinScan::assignRegOrStackSlotAtInterval(LiveInterval* cur)
cur->overlapsFrom(*i->first, i->second)) {
DOUT << "\t\t\tspilling(a): " << *i->first << '\n';
earliestStart = std::min(earliestStart, i->first->beginNumber());
+ float SSWeight;
std::vector<LiveInterval*> newIs =
- li_->addIntervalsForSpills(*i->first, loopInfo, *vrm_);
- addStackInterval(i->first, ls_, li_, *vrm_);
+ li_->addIntervalsForSpills(*i->first, loopInfo, *vrm_, SSWeight);
+ addStackInterval(i->first, ls_, li_, SSWeight, *vrm_);
std::copy(newIs.begin(), newIs.end(), std::back_inserter(added));
spilled.insert(reg);
}
@@ -810,9 +814,10 @@ void RALinScan::assignRegOrStackSlotAtInterval(LiveInterval* cur)
cur->overlapsFrom(*i->first, i->second-1)) {
DOUT << "\t\t\tspilling(i): " << *i->first << '\n';
earliestStart = std::min(earliestStart, i->first->beginNumber());
+ float SSWeight;
std::vector<LiveInterval*> newIs =
- li_->addIntervalsForSpills(*i->first, loopInfo, *vrm_);
- addStackInterval(i->first, ls_, li_, *vrm_);
+ li_->addIntervalsForSpills(*i->first, loopInfo, *vrm_, SSWeight);
+ addStackInterval(i->first, ls_, li_, SSWeight, *vrm_);
std::copy(newIs.begin(), newIs.end(), std::back_inserter(added));
spilled.insert(reg);
}