Commit 318c01bc by Jim Stichnoth

Subzero: Fix -timing-funcs and -timing-focus flags.

1. Generate dummy FunctionXXX function names when either of those flags is given. 2. Remove the browser code that automatically sets F/G prefixes instead of Function/Global, since that performance tweak is no longer relevant. 3. Fix a presumably long-standing bug where -timing-focus would accumulate timings into the TLS copy of the timers, but would then try to print timing info based on the currently-empty GlobalContext copy of the timers. BUG= none R=kschimpf@google.com Review URL: https://codereview.chromium.org/1855683002 .
parent 2a9d186d
......@@ -197,14 +197,18 @@ void Cfg::addCallToProfileSummary() {
void Cfg::translate() {
if (hasError())
return;
if (BuildDefs::dump()) {
if (BuildDefs::timers()) {
const std::string TimingFocusOn = getFlags().getTimingFocusOn();
const std::string Name = getFunctionName().toString();
if (TimingFocusOn == "*" || TimingFocusOn == Name) {
setFocusedTiming();
getContext()->resetTimer(GlobalContext::TSK_Default);
getContext()->setTimerName(GlobalContext::TSK_Default, Name);
if (!TimingFocusOn.empty()) {
const std::string Name = getFunctionName().toString();
if (TimingFocusOn == "*" || TimingFocusOn == Name) {
setFocusedTiming();
getContext()->resetTimer(GlobalContext::TSK_Default);
getContext()->setTimerName(GlobalContext::TSK_Default, Name);
}
}
}
if (BuildDefs::dump()) {
if (isVerbose(IceV_Status)) {
getContext()->getStrDump() << ">>>Translating "
<< getFunctionNameAndSize() << "\n";
......@@ -235,8 +239,10 @@ void Cfg::translate() {
getTarget()->translate();
dump("Final output");
if (getFocusedTiming())
if (getFocusedTiming()) {
getContext()->mergeTimersFromTLS();
getContext()->dumpTimers();
}
}
void Cfg::computeInOutEdges() {
......
......@@ -111,14 +111,12 @@ struct dev_list_flag {};
\
X(DefaultFunctionPrefix, std::string, dev_opt_flag, \
"default-function-prefix", \
cl::desc("Define default function prefix for naming " \
"unnamed functions"), \
cl::init(Ice::BuildDefs::dump() ? "Function" : "F")) \
cl::desc("Define default function prefix for naming unnamed functions"), \
cl::init("Function")) \
\
X(DefaultGlobalPrefix, std::string, dev_opt_flag, "default-global-prefix", \
cl::desc("Define default global prefix for naming " \
"unnamed globals"), \
cl::init(Ice::BuildDefs::dump() ? "Global" : "G")) \
cl::desc("Define default global prefix for naming unnamed globals"), \
cl::init("Global")) \
\
X(DisableHybridAssembly, bool, dev_opt_flag, "no-hybrid-asm", \
cl::desc("Disable hybrid assembly when -filetype=iasm"), cl::init(false)) \
......
......@@ -966,6 +966,10 @@ void GlobalContext::dumpStats(const Cfg *Func) {
}
}
void GlobalContext::mergeTimersFromTLS() {
getTimers()->mergeFrom(ICE_TLS_GET_FIELD(TLS)->Timers);
}
void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) {
if (!BuildDefs::timers())
return;
......@@ -992,7 +996,8 @@ TimerIdT TimerMarker::getTimerIdFromFuncName(GlobalContext *Ctx,
void TimerMarker::push() {
switch (StackID) {
case GlobalContext::TSK_Default:
Active = getFlags().getSubzeroTimingEnabled();
Active = getFlags().getSubzeroTimingEnabled() ||
!getFlags().getTimingFocusOn().empty();
break;
case GlobalContext::TSK_Funcs:
Active = getFlags().getTimeEachFunction();
......
......@@ -352,10 +352,13 @@ public:
/// newTimerStackID() creates a new TimerStack in the global space. It does
/// not affect any TimerStack objects in TLS.
TimerStackIdT newTimerStackID(const std::string &Name);
/// dumpTimers() dumps the global timer data. As such, one probably wants to
/// call mergeTimerStacks() as a prerequisite.
/// dumpTimers() dumps the global timer data. This assumes all the
/// thread-local copies of timer data have been merged into the global timer
/// data.
void dumpTimers(TimerStackIdT StackID = TSK_Default,
bool DumpCumulative = true);
/// Merges the current thread's copy of timer data into the global timer data.
void mergeTimersFromTLS();
/// The following methods affect only the calling thread's TLS timer data.
TimerIdT getTimerID(TimerStackIdT StackID, const std::string &Name);
void pushTimer(TimerIdT ID, TimerStackIdT StackID);
......
......@@ -477,7 +477,14 @@ private:
Prefix);
} else {
Ice::GlobalContext *Ctx = Translator.getContext();
if (Ice::BuildDefs::dump() || !Decl->isInternal()) {
// Synthesize a dummy name if any of the following is true:
// - DUMP is enabled
// - The symbol is external
// - The -timing-funcs flag is enabled
// - The -timing-focus flag is enabled
if (Ice::BuildDefs::dump() || !Decl->isInternal() ||
Ice::getFlags().getTimeEachFunction() ||
!Ice::getFlags().getTimingFocusOn().empty()) {
Decl->setName(Ctx, Translator.createUnnamedName(Prefix, NameIndex));
} else {
Decl->setName(Ctx);
......
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