Subzero: Add rudimentary statistics on generated code.
The following are collected:
- Number of machine instructions emitted
- Number of registers saved/restored in prolog/epilog
- Number of stack frame bytes (non-alloca) allocated
- Number of "spills", or stores to stack slots
- Number of "fills", or loads/operations from stack slots
- Fill+Spill count (sum of above two)
These are somewhat reasonable approximations of code quality, and the primary intention is to compare before-and-after when trying out an optimization.
The statistics are dumped after translating each function. Per-function and cumulative statistics are collected. The output lines have a prefix that is easy to filter.
BUG= none
R=jvoung@chromium.org
Review URL: https://codereview.chromium.org/580633002
diff --git a/src/IceTranslator.cpp b/src/IceTranslator.cpp
index 05332b4..0636b50 100644
--- a/src/IceTranslator.cpp
+++ b/src/IceTranslator.cpp
@@ -71,6 +71,7 @@
}
void Translator::translateFcn(Cfg *Fcn) {
+ Ctx->resetStats();
Func.reset(Fcn);
if (Ctx->getFlags().DisableInternal)
Func->setInternal(false);
@@ -95,6 +96,7 @@
std::cerr << "[Subzero timing] Emit function " << Func->getFunctionName()
<< ": " << TEmit.getElapsedSec() << " sec\n";
}
+ Ctx->dumpStats(Func->getFunctionName());
}
}