Subzero: Improve the output with the --timing-focus=xxx option. Makes sure the percentages represent only the function(s) focused on, and not with respect to the total translation time across all functions. Reset the timings between functions so that --timing-focus=* gives reasonable numbers. Also, adds a timer for the live range construction phase. BUG= none R=jvoung@chromium.org Review URL: https://codereview.chromium.org/640713003
diff --git a/src/IceCfg.cpp b/src/IceCfg.cpp index cf5a81b..83d8e26 100644 --- a/src/IceCfg.cpp +++ b/src/IceCfg.cpp
@@ -71,8 +71,11 @@ return; VerboseMask OldVerboseMask = getContext()->getVerbose(); const IceString &TimingFocusOn = getContext()->getFlags().TimingFocusOn; - if (TimingFocusOn == "*" || TimingFocusOn == getFunctionName()) + if (TimingFocusOn == "*" || TimingFocusOn == getFunctionName()) { setFocusedTiming(); + getContext()->resetTimer(GlobalContext::TSK_Default); + getContext()->setTimerName(GlobalContext::TSK_Default, getFunctionName()); + } bool VerboseFocus = (getContext()->getFlags().VerboseFocusOn == getFunctionName()); if (VerboseFocus)
diff --git a/src/IceCfgNode.cpp b/src/IceCfgNode.cpp index f19552f..cce0199 100644 --- a/src/IceCfgNode.cpp +++ b/src/IceCfgNode.cpp
@@ -393,6 +393,7 @@ } if (Mode != Liveness_Intervals) return; + TimerMarker T1(TimerStack::TT_liveRangeCtor, Func); SizeT NumVars = Liveness->getNumVarsInNode(this); SizeT NumGlobals = Liveness->getNumGlobalVars();
diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp index 80728b0..c8b429f 100644 --- a/src/IceGlobalContext.cpp +++ b/src/IceGlobalContext.cpp
@@ -407,6 +407,17 @@ Timers[StackID].pop(ID); } +void GlobalContext::resetTimer(TimerStackIdT StackID) { + assert(StackID < Timers.size()); + Timers[StackID].reset(); +} + +void GlobalContext::setTimerName(TimerStackIdT StackID, + const IceString &NewName) { + assert(StackID < Timers.size()); + Timers[StackID].setName(NewName); +} + void GlobalContext::dumpStats(const IceString &Name, bool Final) { if (Flags.DumpStats) { if (Final) {
diff --git a/src/IceGlobalContext.h b/src/IceGlobalContext.h index 9968abb..cc5da58 100644 --- a/src/IceGlobalContext.h +++ b/src/IceGlobalContext.h
@@ -164,6 +164,8 @@ TimerStackIdT newTimerStackID(const IceString &Name); void pushTimer(TimerIdT ID, TimerStackIdT StackID = TSK_Default); void popTimer(TimerIdT ID, TimerStackIdT StackID = TSK_Default); + void resetTimer(TimerStackIdT StackID); + void setTimerName(TimerStackIdT StackID, const IceString &NewName); void dumpTimers(TimerStackIdT StackID = TSK_Default, bool DumpCumulative = true);
diff --git a/src/IceTimerTree.cpp b/src/IceTimerTree.cpp index 0cd73dc..618f37f 100644 --- a/src/IceTimerTree.cpp +++ b/src/IceTimerTree.cpp
@@ -97,6 +97,15 @@ } } +void TimerStack::reset() { + StateChangeCount = 0; + FirstTimestamp = LastTimestamp = timestamp(); + LeafTimes.assign(LeafTimes.size(), 0); + for (TimerTreeNode &Node : Nodes) { + Node.Time = 0; + } +} + namespace { typedef std::multimap<double, IceString> DumpMapType;
diff --git a/src/IceTimerTree.def b/src/IceTimerTree.def index 5319b1d..ad5d482 100644 --- a/src/IceTimerTree.def +++ b/src/IceTimerTree.def
@@ -30,6 +30,7 @@ X(initUnhandled) \ X(linearScan) \ X(liveRange) \ + X(liveRangeCtor) \ X(liveness) \ X(livenessLightweight) \ X(llvmConvert) \
diff --git a/src/IceTimerTree.h b/src/IceTimerTree.h index 289ea2d..1f14582 100644 --- a/src/IceTimerTree.h +++ b/src/IceTimerTree.h
@@ -52,15 +52,17 @@ }; TimerStack(const IceString &Name); TimerIdT getTimerID(const IceString &Name); + void setName(const IceString &NewName) { Name = NewName; } void push(TimerIdT ID); void pop(TimerIdT ID); + void reset(); void dump(Ostream &Str, bool DumpCumulative); private: void update(); static double timestamp(); - const IceString Name; - const double FirstTimestamp; + IceString Name; + double FirstTimestamp; double LastTimestamp; uint64_t StateChangeCount; // IDsIndex maps a symbolic timer name to its integer ID.