Commit 4175b2a6 by Jim Stichnoth

Subzero: Also dump live-end info for stack vars under -asm-verbose.

It's sometimes useful to know whether a use of a stack variable (as opposed to a physical register) is the last use of that variable. For example, in a code sequence like: movl %edx, 24(%esp) movl 24(%esp), %edx it would be nice to know whether the code sequence is merely bad (i.e., 24(%esp) will be used later), or horrible (i.e., this ends 24(%esp)'s live range). We add stack variables to the per-instruction live-range-end annotation, but not to the per-block live-in and live-out annotations, because the latter would clutter the output greatly while adding very little actionable information. BUG= https://code.google.com/p/nativeclient/issues/detail?id=4135 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/1113133002
parent 76dcf1a8
...@@ -824,8 +824,8 @@ void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr, ...@@ -824,8 +824,8 @@ void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr,
SizeT NumVars = Src->getNumVars(); SizeT NumVars = Src->getNumVars();
for (SizeT J = 0; J < NumVars; ++J) { for (SizeT J = 0; J < NumVars; ++J) {
const Variable *Var = Src->getVar(J); const Variable *Var = Src->getVar(J);
if (Var->hasReg()) { if (Instr->isLastUse(Var) &&
if (Instr->isLastUse(Var) && --LiveRegCount[Var->getRegNum()] == 0) { (!Var->hasReg() || --LiveRegCount[Var->getRegNum()] == 0)) {
if (First) if (First)
Str << " \t# END="; Str << " \t# END=";
else else
...@@ -835,7 +835,6 @@ void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr, ...@@ -835,7 +835,6 @@ void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr,
} }
} }
} }
}
} }
void updateStats(Cfg *Func, const Inst *I) { void updateStats(Cfg *Func, const Inst *I) {
...@@ -870,8 +869,10 @@ void CfgNode::emit(Cfg *Func) const { ...@@ -870,8 +869,10 @@ void CfgNode::emit(Cfg *Func) const {
Liveness && Func->getContext()->getFlags().getDecorateAsm(); Liveness && Func->getContext()->getFlags().getDecorateAsm();
Str << getAsmName() << ":\n"; Str << getAsmName() << ":\n";
std::vector<SizeT> LiveRegCount(Func->getTarget()->getNumRegisters()); std::vector<SizeT> LiveRegCount(Func->getTarget()->getNumRegisters());
if (DecorateAsm) if (DecorateAsm) {
emitRegisterUsage(Str, Func, this, true, LiveRegCount); const bool IsLiveIn = true;
emitRegisterUsage(Str, Func, this, IsLiveIn, LiveRegCount);
}
for (const Inst &I : Phis) { for (const Inst &I : Phis) {
if (I.isDeleted()) if (I.isDeleted())
...@@ -894,8 +895,10 @@ void CfgNode::emit(Cfg *Func) const { ...@@ -894,8 +895,10 @@ void CfgNode::emit(Cfg *Func) const {
Str << "\n"; Str << "\n";
updateStats(Func, &I); updateStats(Func, &I);
} }
if (DecorateAsm) if (DecorateAsm) {
emitRegisterUsage(Str, Func, this, false, LiveRegCount); const bool IsLiveIn = false;
emitRegisterUsage(Str, Func, this, IsLiveIn, LiveRegCount);
}
} }
// Helper class for emitIAS(). // Helper class for emitIAS().
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment