Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: src/IceRegAlloc.cpp

Issue 1312433004: Weight variables by their number of uses for register allocation. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/IceRegAlloc.cpp
diff --git a/src/IceRegAlloc.cpp b/src/IceRegAlloc.cpp
index 0c15df76a3436e61cf8fe04502b314f6cff17c4c..67c7fdb64905c552cf6141d285b96267a7225713 100644
--- a/src/IceRegAlloc.cpp
+++ b/src/IceRegAlloc.cpp
@@ -99,7 +99,7 @@ void LinearScan::initForGlobal() {
for (Variable *Var : Vars) {
// Explicitly don't consider zero-weight variables, which are meant to be
// spill slots.
- if (Var->getWeight().isZero())
+ if (Var->mustNotHaveReg())
continue;
// Don't bother if the variable has a null live range, which means it was
// never referenced.
@@ -109,7 +109,7 @@ void LinearScan::initForGlobal() {
Unhandled.push_back(Var);
if (Var->hasReg()) {
Var->setRegNumTmp(Var->getRegNum());
- Var->setLiveRangeInfiniteWeight();
+ Var->setMustHaveReg();
UnhandledPrecolored.push_back(Var);
}
}
@@ -173,7 +173,7 @@ void LinearScan::initForInfOnly() {
continue;
if (const Variable *Var = Inst.getDest()) {
if (!Var->getIgnoreLiveness() &&
- (Var->hasReg() || Var->getWeight().isInf())) {
+ (Var->hasReg() || Var->mustHaveReg())) {
if (LRBegin[Var->getIndex()] == Inst::NumberSentinel) {
LRBegin[Var->getIndex()] = Inst.getNumber();
++NumVars;
@@ -187,7 +187,7 @@ void LinearScan::initForInfOnly() {
const Variable *Var = Src->getVar(J);
if (Var->getIgnoreLiveness())
continue;
- if (Var->hasReg() || Var->getWeight().isInf())
+ if (Var->hasReg() || Var->mustHaveReg())
LREnd[Var->getIndex()] = Inst.getNumber();
}
}
@@ -207,7 +207,7 @@ void LinearScan::initForInfOnly() {
Var->untrimLiveRange();
if (Var->hasReg()) {
Var->setRegNumTmp(Var->getRegNum());
- Var->setLiveRangeInfiniteWeight();
+ Var->setMustHaveReg();
UnhandledPrecolored.push_back(Var);
}
--NumVars;
@@ -519,14 +519,14 @@ void LinearScan::handleNoFreeRegisters(IterationState &Iter) {
assert(Item->rangeOverlaps(Iter.Cur));
int32_t RegNum = Item->getRegNumTmp();
assert(Item->hasRegTmp());
- Iter.Weights[RegNum].addWeight(Item->getLiveRange().getWeight());
+ Iter.Weights[RegNum].addWeight(Item->getWeight());
}
// Same as above, but check Inactive ranges instead of Active.
for (const Variable *Item : Inactive) {
int32_t RegNum = Item->getRegNumTmp();
assert(Item->hasRegTmp());
if (Item->rangeOverlaps(Iter.Cur))
- Iter.Weights[RegNum].addWeight(Item->getLiveRange().getWeight());
+ Iter.Weights[RegNum].addWeight(Item->getWeight());
}
// All the weights are now calculated. Find the register with smallest
@@ -539,11 +539,11 @@ void LinearScan::handleNoFreeRegisters(IterationState &Iter) {
MinWeightIndex = i;
}
- if (Iter.Cur->getLiveRange().getWeight() <= Iter.Weights[MinWeightIndex]) {
+ if (Iter.Cur->getWeight() <= Iter.Weights[MinWeightIndex]) {
// Cur doesn't have priority over any other live ranges, so don't allocate
// any register to it, and move it to the Handled state.
Handled.push_back(Iter.Cur);
- if (Iter.Cur->getLiveRange().getWeight().isInf()) {
+ if (Iter.Cur->mustHaveReg()) {
if (Kind == RAK_Phi)
addSpillFill(Iter);
else

Powered by Google App Engine
This is Rietveld 408576698