OSDN Git Service

Subzero: Also dump live-end info for stack vars under -asm-verbose.
authorJim Stichnoth <stichnot@chromium.org>
Thu, 30 Apr 2015 19:26:22 +0000 (12:26 -0700)
committerJim Stichnoth <stichnot@chromium.org>
Thu, 30 Apr 2015 19:26:22 +0000 (12:26 -0700)
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

src/IceCfgNode.cpp

index b5e9d86..a9b34fc 100644 (file)
@@ -824,15 +824,14 @@ 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 (Var->hasReg()) {
-        if (Instr->isLastUse(Var) && --LiveRegCount[Var->getRegNum()] == 0) {
-          if (First)
-            Str << " \t# END=";
-          else
-            Str << ",";
-          Var->emit(Func);
-          First = false;
-        }
+      if (Instr->isLastUse(Var) &&
+          (!Var->hasReg() || --LiveRegCount[Var->getRegNum()] == 0)) {
+        if (First)
+          Str << " \t# END=";
+        else
+          Str << ",";
+        Var->emit(Func);
+        First = false;
       }
     }
   }
@@ -870,8 +869,10 @@ void CfgNode::emit(Cfg *Func) const {
       Liveness && Func->getContext()->getFlags().getDecorateAsm();
   Str << getAsmName() << ":\n";
   std::vector<SizeT> LiveRegCount(Func->getTarget()->getNumRegisters());
-  if (DecorateAsm)
-    emitRegisterUsage(Str, Func, this, true, LiveRegCount);
+  if (DecorateAsm) {
+    const bool IsLiveIn = true;
+    emitRegisterUsage(Str, Func, this, IsLiveIn, LiveRegCount);
+  }
 
   for (const Inst &I : Phis) {
     if (I.isDeleted())
@@ -894,8 +895,10 @@ void CfgNode::emit(Cfg *Func) const {
     Str << "\n";
     updateStats(Func, &I);
   }
-  if (DecorateAsm)
-    emitRegisterUsage(Str, Func, this, false, LiveRegCount);
+  if (DecorateAsm) {
+    const bool IsLiveIn = false;
+    emitRegisterUsage(Str, Func, this, IsLiveIn, LiveRegCount);
+  }
 }
 
 // Helper class for emitIAS().