aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-08-22 20:20:42 +0000
committerChris Lattner <sabre@nondot.org>2005-08-22 20:20:42 +0000
commita6c1750362ffb5e8c5b5b5232442cd4c49eafdc8 (patch)
treef30328e159fbd92a6696f5333b7985f77cc0ced6
parent47c088941948f7ab66a3e34f4cbd20fc74065a3d (diff)
Move some code in the register assignment case that only needs to happen if
we spill out of the fast path. The scan of active_ and the calls to updateSpillWeights don't need to happen unless a spill occurs. This reduces debug llc time of kc++ with ppc from 187.3s to 183.2s. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22971 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/RegAllocLinearScan.cpp43
1 files changed, 26 insertions, 17 deletions
diff --git a/lib/CodeGen/RegAllocLinearScan.cpp b/lib/CodeGen/RegAllocLinearScan.cpp
index e85826c047..ce58e59cb5 100644
--- a/lib/CodeGen/RegAllocLinearScan.cpp
+++ b/lib/CodeGen/RegAllocLinearScan.cpp
@@ -365,23 +365,11 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
PhysRegTracker backupPrt = *prt_;
- std::vector<float> SpillWeights;
- SpillWeights.assign(mri_->getNumRegs(), 0.0);
-
+ std::vector<std::pair<unsigned, float> > SpillWeightsToAdd;
unsigned StartPosition = cur->beginNumber();
- // for each interval in active, update spill weights.
- for (IntervalPtrs::const_iterator i = active_.begin(), e = active_.end();
- i != e; ++i) {
- unsigned reg = i->first->reg;
- assert(MRegisterInfo::isVirtualRegister(reg) &&
- "Can only allocate virtual registers!");
- reg = vrm_->getPhys(reg);
- updateSpillWeights(SpillWeights, reg, i->first->weight, mri_);
- }
-
// for every interval in inactive we overlap with, mark the
- // register as not free and update spill weights
+ // register as not free and update spill weights.
for (IntervalPtrs::const_iterator i = inactive_.begin(),
e = inactive_.end(); i != e; ++i) {
if (cur->overlapsFrom(*i->first, i->second-1)) {
@@ -390,7 +378,7 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
"Can only allocate virtual registers!");
reg = vrm_->getPhys(reg);
prt_->addRegUse(reg);
- updateSpillWeights(SpillWeights, reg, i->first->weight, mri_);
+ SpillWeightsToAdd.push_back(std::make_pair(reg, i->first->weight));
}
}
@@ -407,14 +395,19 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
if (cur->overlapsFrom(*I, II)) {
unsigned reg = I->reg;
prt_->addRegUse(reg);
- updateSpillWeights(SpillWeights, reg, I->weight, mri_);
+ SpillWeightsToAdd.push_back(std::make_pair(reg, I->weight));
}
}
}
+ // Using the newly updated prt_ object, which includes conflicts in the
+ // future, see if there are any registers available.
unsigned physReg = getFreePhysReg(cur);
- // restore the physical register tracker
+
+ // Restore the physical register tracker, removing information about the
+ // future.
*prt_ = backupPrt;
+
// if we find a free register, we are done: assign this virtual to
// the free physical register and add this interval to the active
// list.
@@ -428,6 +421,22 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
}
DEBUG(std::cerr << "no free registers\n");
+ // Compile the spill weights into an array that is better for scanning.
+ std::vector<float> SpillWeights(mri_->getNumRegs(), 0.0);
+ for (std::vector<std::pair<unsigned, float> >::iterator
+ I = SpillWeightsToAdd.begin(), E = SpillWeightsToAdd.end(); I != E; ++I)
+ updateSpillWeights(SpillWeights, I->first, I->second, mri_);
+
+ // for each interval in active, update spill weights.
+ for (IntervalPtrs::const_iterator i = active_.begin(), e = active_.end();
+ i != e; ++i) {
+ unsigned reg = i->first->reg;
+ assert(MRegisterInfo::isVirtualRegister(reg) &&
+ "Can only allocate virtual registers!");
+ reg = vrm_->getPhys(reg);
+ updateSpillWeights(SpillWeights, reg, i->first->weight, mri_);
+ }
+
DEBUG(std::cerr << "\tassigning stack slot at interval "<< *cur << ":\n");
float minWeight = float(HUGE_VAL);