aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2009-04-20 17:23:48 +0000
committerEvan Cheng <evan.cheng@apple.com>2009-04-20 17:23:48 +0000
commitc4f718a3a7990a13888836902ecac034a9d6a235 (patch)
treec196683e4694215760aebe07f51b83f590c23fd2
parent2bdf490d71ca03396dc6790adc806fa77c5e437a (diff)
downloadexternal_llvm-c4f718a3a7990a13888836902ecac034a9d6a235.zip
external_llvm-c4f718a3a7990a13888836902ecac034a9d6a235.tar.gz
external_llvm-c4f718a3a7990a13888836902ecac034a9d6a235.tar.bz2
- Remove an arbitrary spill weight tweak that should not have been there.
- Find more reloads from SS. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69606 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/RegAllocLinearScan.cpp31
1 files changed, 26 insertions, 5 deletions
diff --git a/lib/CodeGen/RegAllocLinearScan.cpp b/lib/CodeGen/RegAllocLinearScan.cpp
index ba2d3aa..c738315 100644
--- a/lib/CodeGen/RegAllocLinearScan.cpp
+++ b/lib/CodeGen/RegAllocLinearScan.cpp
@@ -554,9 +554,6 @@ void RALinScan::updateSpillWeights(std::vector<float> &Weights,
SmallSet<unsigned, 4> Processed;
SmallSet<unsigned, 4> SuperAdded;
SmallVector<unsigned, 4> Supers;
- // Unfavor downgraded registers for spilling.
- if (DowngradedRegs.count(reg))
- weight *= 2.0f;
Weights[reg] += weight;
Processed.insert(reg);
for (const unsigned* as = tri_->getAliasSet(reg); *as; ++as) {
@@ -1015,8 +1012,32 @@ void RALinScan::assignRegOrStackSlotAtInterval(LiveInterval* cur)
// Merge added with unhandled. Note that we have already sorted
// intervals returned by addIntervalsForSpills by their starting
// point.
- for (unsigned i = 0, e = added.size(); i != e; ++i)
- unhandled_.push(added[i]);
+ // This also update the NextReloadMap. That is, it adds mapping from a
+ // register defined by a reload from SS to the next reload from SS in the
+ // same basic block.
+ MachineBasicBlock *LastReloadMBB = 0;
+ LiveInterval *LastReload = 0;
+ int LastReloadSS = VirtRegMap::NO_STACK_SLOT;
+ for (unsigned i = 0, e = added.size(); i != e; ++i) {
+ LiveInterval *ReloadLi = added[i];
+ if (ReloadLi->weight == HUGE_VALF &&
+ li_->getApproximateInstructionCount(*ReloadLi) == 0) {
+ unsigned ReloadIdx = ReloadLi->beginNumber();
+ MachineBasicBlock *ReloadMBB = li_->getMBBFromIndex(ReloadIdx);
+ int ReloadSS = vrm_->getStackSlot(ReloadLi->reg);
+ if (LastReloadMBB == ReloadMBB && LastReloadSS == ReloadSS) {
+ // Last reload of same SS is in the same MBB. We want to try to
+ // allocate both reloads the same register and make sure the reg
+ // isn't clobbered in between if at all possible.
+ assert(LastReload->beginNumber() < ReloadIdx);
+ NextReloadMap.insert(std::make_pair(LastReload->reg, ReloadLi->reg));
+ }
+ LastReloadMBB = ReloadMBB;
+ LastReload = ReloadLi;
+ LastReloadSS = ReloadSS;
+ }
+ unhandled_.push(ReloadLi);
+ }
return;
}