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

Unified Diff: src/IceRegAlloc.cpp

Issue 2172313002: Subzero : Live Range Splitting after initial Register Allocation (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Cleanup Created 4 years, 5 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 06631bfe2125b55d5f420bde7c2447cddea780d6..c308f0da918a0080d3f92fd4fc2b3152a93e7f5c 100644
--- a/src/IceRegAlloc.cpp
+++ b/src/IceRegAlloc.cpp
@@ -113,7 +113,6 @@ void LinearScan::initForGlobal() {
// register allocation since no overlap opportunities should be available and
// it's more expensive to look for opportunities.
FindOverlap = (Kind != RAK_Phi);
- const VarList &Vars = Func->getVariables();
Unhandled.reserve(Vars.size());
UnhandledPrecolored.reserve(Vars.size());
// Gather the live ranges of all variables and add them to the Unhandled set.
@@ -168,7 +167,6 @@ bool LinearScan::livenessValidateIntervals(
if (!BuildDefs::dump())
return false;
- const VarList &Vars = Func->getVariables();
OstreamLocker L(Ctx);
Ostream &Str = Ctx->getStrDump();
for (SizeT VarNum : DefsWithoutUses) {
@@ -212,7 +210,6 @@ void LinearScan::initForInfOnly() {
FindPreference = false;
FindOverlap = false;
SizeT NumVars = 0;
- const VarList &Vars = Func->getVariables();
// Iterate across all instructions and record the begin and end of the live
// range for each variable that is pre-colored or infinite weight.
@@ -325,13 +322,22 @@ void LinearScan::initForSecondChance() {
}
}
-void LinearScan::init(RegAllocKind Kind) {
+void LinearScan::init(RegAllocKind Kind, CfgSet<Variable *> ExtraVars,
+ CfgSet<Variable *> ExcludeVars) {
this->Kind = Kind;
Unhandled.clear();
UnhandledPrecolored.clear();
Handled.clear();
Inactive.clear();
Active.clear();
+ Vars.clear();
Jim Stichnoth 2016/07/29 17:04:07 You may want to do something like: Vars.reserve
manasijm 2016/08/01 22:20:04 Done.
+ for (auto *Var : Func->getVariables()) {
+ if (ExcludeVars.find(Var) == ExcludeVars.end())
Jim Stichnoth 2016/07/29 17:04:07 I haven't studied the code that manages ExtraVars
+ Vars.push_back(Var);
Jim Stichnoth 2016/07/29 17:04:07 I think we prefer emplace_back() instead of push_b
manasijm 2016/08/01 22:20:04 Done.
+ }
+ for (auto *ExtraVar : ExtraVars) {
Jim Stichnoth 2016/07/29 17:04:07 You might be able to do something more compact lik
manasijm 2016/08/01 22:20:04 Acknowledged.
+ Vars.push_back(ExtraVar);
+ }
SizeT NumRegs = Target->getNumRegisters();
RegAliases.resize(NumRegs);
@@ -464,8 +470,13 @@ void LinearScan::handleActiveRangeExpiredOrInactive(const Variable *Cur) {
assert(Item->hasRegTmp());
const auto &Aliases = *RegAliases[Item->getRegNumTmp()];
for (RegNumT RegAlias : RegNumBVIter(Aliases)) {
- --RegUses[RegAlias];
- assert(RegUses[RegAlias] >= 0);
+ if (SplittingMode) {
+ if (RegUses[RegAlias] > 0)
Jim Stichnoth 2016/07/29 17:04:07 This seems really suspicious, and I can't work out
manasijm 2016/08/01 22:20:04 Should have removed it before submitting. Thanks
+ --RegUses[RegAlias];
+ } else {
+ --RegUses[RegAlias];
+ assert(RegUses[RegAlias] >= 0);
+ }
}
}
}
@@ -962,7 +973,8 @@ void LinearScan::scan(const SmallBitVector &RegMaskFull, bool Randomized) {
} else {
// Fallback: there are no free registers, so we look for the lowest-weight
// register and see if Cur has higher weight.
- handleNoFreeRegisters(Iter);
+ if (!SplittingMode)
manasijm 2016/08/01 22:20:04 This turned out to be unnecessary too.
+ handleNoFreeRegisters(Iter);
}
dump(Func);
}

Powered by Google App Engine
This is Rietveld 408576698