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() { ...@@ -197,14 +197,18 @@ void Cfg::addCallToProfileSummary() {
void Cfg::translate() { void Cfg::translate() {
if (hasError()) if (hasError())
return; return;
if (BuildDefs::dump()) { if (BuildDefs::timers()) {
const std::string TimingFocusOn = getFlags().getTimingFocusOn(); const std::string TimingFocusOn = getFlags().getTimingFocusOn();
const std::string Name = getFunctionName().toString(); if (!TimingFocusOn.empty()) {
if (TimingFocusOn == "*" || TimingFocusOn == Name) { const std::string Name = getFunctionName().toString();
setFocusedTiming(); if (TimingFocusOn == "*" || TimingFocusOn == Name) {
getContext()->resetTimer(GlobalContext::TSK_Default); setFocusedTiming();
getContext()->setTimerName(GlobalContext::TSK_Default, Name); getContext()->resetTimer(GlobalContext::TSK_Default);
getContext()->setTimerName(GlobalContext::TSK_Default, Name);
}
} }
}
if (BuildDefs::dump()) {
if (isVerbose(IceV_Status)) { if (isVerbose(IceV_Status)) {
getContext()->getStrDump() << ">>>Translating " getContext()->getStrDump() << ">>>Translating "
<< getFunctionNameAndSize() << "\n"; << getFunctionNameAndSize() << "\n";
...@@ -235,8 +239,10 @@ void Cfg::translate() { ...@@ -235,8 +239,10 @@ void Cfg::translate() {
getTarget()->translate(); getTarget()->translate();
dump("Final output"); dump("Final output");
if (getFocusedTiming()) if (getFocusedTiming()) {
getContext()->mergeTimersFromTLS();
getContext()->dumpTimers(); getContext()->dumpTimers();
}
} }
void Cfg::computeInOutEdges() { void Cfg::computeInOutEdges() {
......
...@@ -111,14 +111,12 @@ struct dev_list_flag {}; ...@@ -111,14 +111,12 @@ struct dev_list_flag {};
\ \
X(DefaultFunctionPrefix, std::string, dev_opt_flag, \ X(DefaultFunctionPrefix, std::string, dev_opt_flag, \
"default-function-prefix", \ "default-function-prefix", \
cl::desc("Define default function prefix for naming " \ cl::desc("Define default function prefix for naming unnamed functions"), \
"unnamed functions"), \ cl::init("Function")) \
cl::init(Ice::BuildDefs::dump() ? "Function" : "F")) \
\ \
X(DefaultGlobalPrefix, std::string, dev_opt_flag, "default-global-prefix", \ X(DefaultGlobalPrefix, std::string, dev_opt_flag, "default-global-prefix", \
cl::desc("Define default global prefix for naming " \ cl::desc("Define default global prefix for naming unnamed globals"), \
"unnamed globals"), \ cl::init("Global")) \
cl::init(Ice::BuildDefs::dump() ? "Global" : "G")) \
\ \
X(DisableHybridAssembly, bool, dev_opt_flag, "no-hybrid-asm", \ X(DisableHybridAssembly, bool, dev_opt_flag, "no-hybrid-asm", \
cl::desc("Disable hybrid assembly when -filetype=iasm"), cl::init(false)) \ cl::desc("Disable hybrid assembly when -filetype=iasm"), cl::init(false)) \
......
...@@ -966,6 +966,10 @@ void GlobalContext::dumpStats(const Cfg *Func) { ...@@ -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) { void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) {
if (!BuildDefs::timers()) if (!BuildDefs::timers())
return; return;
...@@ -992,7 +996,8 @@ TimerIdT TimerMarker::getTimerIdFromFuncName(GlobalContext *Ctx, ...@@ -992,7 +996,8 @@ TimerIdT TimerMarker::getTimerIdFromFuncName(GlobalContext *Ctx,
void TimerMarker::push() { void TimerMarker::push() {
switch (StackID) { switch (StackID) {
case GlobalContext::TSK_Default: case GlobalContext::TSK_Default:
Active = getFlags().getSubzeroTimingEnabled(); Active = getFlags().getSubzeroTimingEnabled() ||
!getFlags().getTimingFocusOn().empty();
break; break;
case GlobalContext::TSK_Funcs: case GlobalContext::TSK_Funcs:
Active = getFlags().getTimeEachFunction(); Active = getFlags().getTimeEachFunction();
......
...@@ -352,10 +352,13 @@ public: ...@@ -352,10 +352,13 @@ public:
/// newTimerStackID() creates a new TimerStack in the global space. It does /// newTimerStackID() creates a new TimerStack in the global space. It does
/// not affect any TimerStack objects in TLS. /// not affect any TimerStack objects in TLS.
TimerStackIdT newTimerStackID(const std::string &Name); TimerStackIdT newTimerStackID(const std::string &Name);
/// dumpTimers() dumps the global timer data. As such, one probably wants to /// dumpTimers() dumps the global timer data. This assumes all the
/// call mergeTimerStacks() as a prerequisite. /// thread-local copies of timer data have been merged into the global timer
/// data.
void dumpTimers(TimerStackIdT StackID = TSK_Default, void dumpTimers(TimerStackIdT StackID = TSK_Default,
bool DumpCumulative = true); 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. /// The following methods affect only the calling thread's TLS timer data.
TimerIdT getTimerID(TimerStackIdT StackID, const std::string &Name); TimerIdT getTimerID(TimerStackIdT StackID, const std::string &Name);
void pushTimer(TimerIdT ID, TimerStackIdT StackID); void pushTimer(TimerIdT ID, TimerStackIdT StackID);
......
...@@ -477,7 +477,14 @@ private: ...@@ -477,7 +477,14 @@ private:
Prefix); Prefix);
} else { } else {
Ice::GlobalContext *Ctx = Translator.getContext(); 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)); Decl->setName(Ctx, Translator.createUnnamedName(Prefix, NameIndex));
} else { } else {
Decl->setName(Ctx); 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