Commit 1c44d819 by Jim Stichnoth

Subzero: Disable stats and timers under the MINIMAL build.

Specifically, don't bother to collect "-timing" and "-szstats" information since they anyway don't get printed out under the MINIMAL build. This is done by using the ALLOW_DUMP flag to guard whether code and timing stats are collected. This ends up reducing the native translator size by about 3%. ALLOW_DUMP is used as the guard since it already guards the output of the collected data - no sense collecting the data if it can never be printed out. To minimize the number of ALLOW_DUMP tests, we push the tests into the timing/stats class methods. BUG= none R=jvoung@chromium.org, kschimpf@google.com Review URL: https://codereview.chromium.org/788713002
parent a49e9d9c
......@@ -68,11 +68,13 @@ bool Cfg::hasComputedFrame() const { return getTarget()->hasComputedFrame(); }
void Cfg::translate() {
if (hasError())
return;
const IceString &TimingFocusOn = getContext()->getFlags().TimingFocusOn;
if (TimingFocusOn == "*" || TimingFocusOn == getFunctionName()) {
setFocusedTiming();
getContext()->resetTimer(GlobalContext::TSK_Default);
getContext()->setTimerName(GlobalContext::TSK_Default, getFunctionName());
if (ALLOW_DUMP) {
const IceString &TimingFocusOn = getContext()->getFlags().TimingFocusOn;
if (TimingFocusOn == "*" || TimingFocusOn == getFunctionName()) {
setFocusedTiming();
getContext()->resetTimer(GlobalContext::TSK_Default);
getContext()->setTimerName(GlobalContext::TSK_Default, getFunctionName());
}
}
TimerMarker T(TimerStack::TT_translate, this);
......
......@@ -883,7 +883,7 @@ void Converter::convertFunctions() {
continue;
TimerIdT TimerID = 0;
if (Ctx->getFlags().TimeEachFunction) {
if (ALLOW_DUMP && Ctx->getFlags().TimeEachFunction) {
TimerID = Ctx->getTimerID(StackID, I.getName());
Ctx->pushTimer(TimerID, StackID);
}
......@@ -891,7 +891,7 @@ void Converter::convertFunctions() {
Cfg *Fcn = FunctionConverter.convertFunction(&I);
translateFcn(Fcn);
if (Ctx->getFlags().TimeEachFunction)
if (ALLOW_DUMP && Ctx->getFlags().TimeEachFunction)
Ctx->popTimer(TimerID, StackID);
}
......
......@@ -114,8 +114,10 @@ GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit,
TestPrefix(TestPrefix), Flags(Flags), HasEmittedFirstMethod(false),
RNG(""), ObjectWriter() {
// Pre-register built-in stack names.
newTimerStackID("Total across all functions");
newTimerStackID("Per-function summary");
if (ALLOW_DUMP) {
newTimerStackID("Total across all functions");
newTimerStackID("Per-function summary");
}
if (Flags.UseELFWriter) {
ObjectWriter.reset(new ELFObjectWriter(*this, *ELFStr));
}
......@@ -221,7 +223,7 @@ IceString GlobalContext::mangleName(const IceString &Name) const {
// _Z3barxyz ==> ZN6Prefix3barExyz
// An unmangled, extern "C" style name, gets a simple prefix:
// bar ==> Prefixbar
if (getTestPrefix().empty())
if (!ALLOW_DUMP || getTestPrefix().empty())
return Name;
unsigned PrefixLength = getTestPrefix().length();
......@@ -438,6 +440,8 @@ TimerIdT GlobalContext::getTimerID(TimerStackIdT StackID,
}
TimerStackIdT GlobalContext::newTimerStackID(const IceString &Name) {
if (!ALLOW_DUMP)
return 0;
TimerStackIdT NewID = Timers.size();
Timers.push_back(TimerStack(Name));
return NewID;
......@@ -485,10 +489,12 @@ void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) {
}
TimerMarker::TimerMarker(TimerIdT ID, const Cfg *Func)
: ID(ID), Ctx(Func->getContext()),
Active(Func->getFocusedTiming() || Ctx->getFlags().SubzeroTimingEnabled) {
if (Active)
Ctx->pushTimer(ID);
: ID(ID), Ctx(Func->getContext()), Active(false) {
if (ALLOW_DUMP) {
Active = Func->getFocusedTiming() || Ctx->getFlags().SubzeroTimingEnabled;
if (Active)
Ctx->pushTimer(ID);
}
}
} // end of namespace Ice
......@@ -161,25 +161,38 @@ public:
ELFObjectWriter *getObjectWriter() const { return ObjectWriter.get(); }
// Reset stats at the beginning of a function.
void resetStats() { StatsFunction.reset(); }
void resetStats() {
if (ALLOW_DUMP)
StatsFunction.reset();
}
void dumpStats(const IceString &Name, bool Final = false);
void statsUpdateEmitted(uint32_t InstCount) {
if (!ALLOW_DUMP)
return;
StatsFunction.updateEmitted(InstCount);
StatsCumulative.updateEmitted(InstCount);
}
void statsUpdateRegistersSaved(uint32_t Num) {
if (!ALLOW_DUMP)
return;
StatsFunction.updateRegistersSaved(Num);
StatsCumulative.updateRegistersSaved(Num);
}
void statsUpdateFrameBytes(uint32_t Bytes) {
if (!ALLOW_DUMP)
return;
StatsFunction.updateFrameBytes(Bytes);
StatsCumulative.updateFrameBytes(Bytes);
}
void statsUpdateSpills() {
if (!ALLOW_DUMP)
return;
StatsFunction.updateSpills();
StatsCumulative.updateSpills();
}
void statsUpdateFills() {
if (!ALLOW_DUMP)
return;
StatsFunction.updateFills();
StatsCumulative.updateFills();
}
......@@ -234,21 +247,24 @@ class TimerMarker {
public:
TimerMarker(TimerIdT ID, GlobalContext *Ctx)
: ID(ID), Ctx(Ctx), Active(Ctx->getFlags().SubzeroTimingEnabled) {
if (Active)
Ctx->pushTimer(ID);
: ID(ID), Ctx(Ctx), Active(false) {
if (ALLOW_DUMP) {
Active = Ctx->getFlags().SubzeroTimingEnabled;
if (Active)
Ctx->pushTimer(ID);
}
}
TimerMarker(TimerIdT ID, const Cfg *Func);
~TimerMarker() {
if (Active)
if (ALLOW_DUMP && Active)
Ctx->popTimer(ID);
}
private:
TimerIdT ID;
GlobalContext *const Ctx;
const bool Active;
bool Active;
};
} // end of namespace Ice
......
......@@ -22,6 +22,8 @@ namespace Ice {
TimerStack::TimerStack(const IceString &Name)
: Name(Name), FirstTimestamp(timestamp()), LastTimestamp(FirstTimestamp),
StateChangeCount(0), StackTop(0) {
if (!ALLOW_DUMP)
return;
Nodes.resize(1); // Reserve Nodes[0] for the root node.
IDs.resize(TT__num);
#define STR(s) #s
......@@ -36,6 +38,8 @@ TimerStack::TimerStack(const IceString &Name)
// Returns the unique timer ID for the given Name, creating a new ID
// if needed.
TimerIdT TimerStack::getTimerID(const IceString &Name) {
if (!ALLOW_DUMP)
return 0;
if (IDsIndex.find(Name) == IDsIndex.end()) {
IDsIndex[Name] = IDs.size();
IDs.push_back(Name);
......@@ -45,6 +49,8 @@ TimerIdT TimerStack::getTimerID(const IceString &Name) {
// Pushes a new marker onto the timer stack.
void TimerStack::push(TimerIdT ID) {
if (!ALLOW_DUMP)
return;
const bool UpdateCounts = false;
update(UpdateCounts);
if (Nodes[StackTop].Children.size() <= ID)
......@@ -62,6 +68,8 @@ void TimerStack::push(TimerIdT ID) {
// Pop the top marker from the timer stack. Validates via assert()
// that the expected marker is popped.
void TimerStack::pop(TimerIdT ID) {
if (!ALLOW_DUMP)
return;
const bool UpdateCounts = true;
update(UpdateCounts);
assert(StackTop);
......@@ -77,6 +85,8 @@ void TimerStack::pop(TimerIdT ID) {
// At a state change (e.g. push or pop), updates the flat and
// cumulative timings for everything on the timer stack.
void TimerStack::update(bool UpdateCounts) {
if (!ALLOW_DUMP)
return;
++StateChangeCount;
// Whenever the stack is about to change, we grab the time delta
// since the last change and add it to all active cumulative
......@@ -111,6 +121,8 @@ void TimerStack::update(bool UpdateCounts) {
}
void TimerStack::reset() {
if (!ALLOW_DUMP)
return;
StateChangeCount = 0;
FirstTimestamp = LastTimestamp = timestamp();
LeafTimes.assign(LeafTimes.size(), 0);
......
......@@ -1112,7 +1112,7 @@ public:
CachedNumGlobalValueIDs(Context->getNumGlobalIDs()),
NextLocalInstIndex(Context->getNumGlobalIDs()),
InstIsTerminating(false) {
if (getFlags().TimeEachFunction)
if (ALLOW_DUMP && getFlags().TimeEachFunction)
getTranslator().getContext()->pushTimer(
getTranslator().getContext()->getTimerID(
Ice::GlobalContext::TSK_Funcs, FuncDecl->getName()),
......@@ -1210,7 +1210,7 @@ private:
static const uint64_t AlignPowerLimit = 29;
void popTimerIfTimingEachFunction() const {
if (getFlags().TimeEachFunction) {
if (ALLOW_DUMP && getFlags().TimeEachFunction) {
getTranslator().getContext()->popTimer(
getTranslator().getContext()->getTimerID(
Ice::GlobalContext::TSK_Funcs, Func->getFunctionName()),
......
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