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

Unified Diff: src/IceRegAlloc.cpp

Issue 1368993004: Subzero: Improve usability of liveness-related tools. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix comments Created 5 years, 3 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 d9837d967c0a63d8d87926742b0b479e760e4597..200f1641b460e03f173c108709d6890fe89a3c47 100644
--- a/src/IceRegAlloc.cpp
+++ b/src/IceRegAlloc.cpp
@@ -168,10 +168,21 @@ void LinearScan::initForInfOnly() {
// range for each variable that is pre-colored or infinite weight.
CfgVector<InstNumberT> LRBegin(Vars.size(), Inst::NumberSentinel);
CfgVector<InstNumberT> LREnd(Vars.size(), Inst::NumberSentinel);
+ llvm::SmallVector<SizeT, 10> DefWithoutUse, UseBeforeDef;
John 2015/09/25 23:02:16 Maybe plural? I.e., DefsWithoutUses
Jim Stichnoth 2015/09/25 23:56:01 Done.
for (CfgNode *Node : Func->getNodes()) {
for (Inst &Inst : Node->getInsts()) {
if (Inst.isDeleted())
continue;
+ FOREACH_VAR_IN_INST(Var, Inst) {
+ if (Var->getIgnoreLiveness())
+ continue;
+ if (Var->hasReg() || Var->mustHaveReg()) {
+ SizeT VarNum = Var->getIndex();
+ LREnd[VarNum] = Inst.getNumber();
+ if (!Var->getIsArg() && LRBegin[VarNum] == Inst::NumberSentinel)
+ UseBeforeDef.push_back(VarNum);
+ }
+ }
if (const Variable *Var = Inst.getDest()) {
if (!Var->getIgnoreLiveness() &&
(Var->hasReg() || Var->mustHaveReg())) {
@@ -181,12 +192,6 @@ void LinearScan::initForInfOnly() {
}
}
}
- FOREACH_VAR_IN_INST(Var, Inst) {
- if (Var->getIgnoreLiveness())
- continue;
- if (Var->hasReg() || Var->mustHaveReg())
- LREnd[Var->getIndex()] = Inst.getNumber();
- }
}
}
@@ -195,7 +200,10 @@ void LinearScan::initForInfOnly() {
for (SizeT i = 0; i < Vars.size(); ++i) {
Variable *Var = Vars[i];
if (LRBegin[i] != Inst::NumberSentinel) {
- assert(LREnd[i] != Inst::NumberSentinel);
+ if (LREnd[i] == Inst::NumberSentinel) {
+ DefWithoutUse.push_back(i);
+ continue;
+ }
Unhandled.push_back(Var);
Var->resetLiveRange();
Var->addLiveRange(LRBegin[i], LREnd[i]);
@@ -208,6 +216,23 @@ void LinearScan::initForInfOnly() {
--NumVars;
}
}
+ if (!DefWithoutUse.empty() || !UseBeforeDef.empty()) {
+ if (BuildDefs::dump()) {
John 2015/09/25 23:02:16 same thing here if (DefWithoutUse.empty() && UseB
Jim Stichnoth 2015/09/25 23:56:01 Done.
+ OstreamLocker L(Ctx);
+ Ostream &Str = Ctx->getStrDump();
+ for (SizeT i : DefWithoutUse) {
John 2015/09/25 23:02:16 'i' is weird here. I mostly see single-letter vari
Jim Stichnoth 2015/09/25 23:56:01 Done.
+ Variable *Var = Vars[i];
+ Str << "LR def without use, instruction " << LRBegin[i] << ", variable "
+ << Var->getName(Func) << "\n";
+ }
+ for (SizeT i : UseBeforeDef) {
+ Variable *Var = Vars[i];
+ Str << "LR use before def, instruction " << LREnd[i] << ", variable "
+ << Var->getName(Func) << "\n";
+ }
+ }
+ llvm::report_fatal_error("initForInfOnly: Liveness error");
+ }
// This isn't actually a fatal condition, but it would be nice to know if we
// somehow pre-calculated Unhandled's size wrong.
assert(NumVars == 0);

Powered by Google App Engine
This is Rietveld 408576698