Chromium Code Reviews| 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); |