Chromium Code Reviews| Index: src/IceCfgNode.cpp |
| diff --git a/src/IceCfgNode.cpp b/src/IceCfgNode.cpp |
| index fb2ab396c25b04507549c76b73a899e473558818..55a6361c71019eb64a108bc89f55362390c4d6a5 100644 |
| --- a/src/IceCfgNode.cpp |
| +++ b/src/IceCfgNode.cpp |
| @@ -794,20 +794,30 @@ void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node, |
| Str << "\t\t\t\t# LiveOut="; |
| } |
| if (!Live->empty()) { |
| - bool First = true; |
| + std::vector<Variable *> LiveRegs; |
| for (SizeT i = 0; i < Live->size(); ++i) { |
| if ((*Live)[i]) { |
| Variable *Var = Liveness->getVariable(i, Node); |
| if (Var->hasReg()) { |
| if (IsLiveIn) |
| ++LiveRegCount[Var->getRegNum()]; |
| - if (!First) |
| - Str << ","; |
| - First = false; |
| - Var->emit(Func); |
| + LiveRegs.push_back(Var); |
| } |
| } |
| } |
| + // Sort the variables by regnum so they are always printed in a |
| + // familiar order. |
| + std::sort(LiveRegs.begin(), LiveRegs.end(), |
| + [](const Variable *V1, const Variable *V2) { |
| + return V1->getRegNum() < V2->getRegNum(); |
| + }); |
| + bool First = true; |
| + for (Variable *Var : LiveRegs) { |
| + if (!First) |
| + Str << ","; |
| + First = false; |
| + Var->emit(Func); |
| + } |
| } |
| Str << "\n"; |
| } |
| @@ -825,8 +835,13 @@ void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr, |
| SizeT NumVars = Src->getNumVars(); |
| for (SizeT J = 0; J < NumVars; ++J) { |
| const Variable *Var = Src->getVar(J); |
| - if (Instr->isLastUse(Var) && |
| - (!Var->hasReg() || --LiveRegCount[Var->getRegNum()] == 0)) { |
| + bool ShouldEmit = Instr->isLastUse(Var); |
| + // Don't report end of live range until the live count reaches 0. |
| + if (Var->hasReg()) { |
|
Karl
2015/05/26 20:47:47
Nit: make it more obvious that the -- is the speci
Jim Stichnoth
2015/05/26 22:57:17
Done.
|
| + if (--LiveRegCount[Var->getRegNum()]) |
| + ShouldEmit = false; |
| + } |
| + if (ShouldEmit) { |
| if (First) |
| Str << " \t# END="; |
| else |
| @@ -884,12 +899,8 @@ void CfgNode::emit(Cfg *Func) const { |
| for (const Inst &I : Insts) { |
| if (I.isDeleted()) |
| continue; |
| - if (I.isRedundantAssign()) { |
| - Variable *Dest = I.getDest(); |
| - if (DecorateAsm && Dest->hasReg() && !I.isLastUse(I.getSrc(0))) |
| - ++LiveRegCount[Dest->getRegNum()]; |
|
Karl
2015/05/26 20:47:47
I take it that there is a different reason for thi
jvoung (off chromium)
2015/05/26 22:24:41
Hmm yeah I don't remember what this adjustment was
Jim Stichnoth
2015/05/26 22:57:17
Yeah - I don't know why this code was there in the
|
| + if (I.isRedundantAssign()) |
| continue; |
| - } |
| I.emit(Func); |
| if (DecorateAsm) |
| emitLiveRangesEnded(Str, Func, &I, LiveRegCount); |