Commit d14b1a02 by Jim Stichnoth

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
parent 109fa152
...@@ -71,8 +71,11 @@ void Cfg::translate() { ...@@ -71,8 +71,11 @@ void Cfg::translate() {
return; return;
VerboseMask OldVerboseMask = getContext()->getVerbose(); VerboseMask OldVerboseMask = getContext()->getVerbose();
const IceString &TimingFocusOn = getContext()->getFlags().TimingFocusOn; const IceString &TimingFocusOn = getContext()->getFlags().TimingFocusOn;
if (TimingFocusOn == "*" || TimingFocusOn == getFunctionName()) if (TimingFocusOn == "*" || TimingFocusOn == getFunctionName()) {
setFocusedTiming(); setFocusedTiming();
getContext()->resetTimer(GlobalContext::TSK_Default);
getContext()->setTimerName(GlobalContext::TSK_Default, getFunctionName());
}
bool VerboseFocus = bool VerboseFocus =
(getContext()->getFlags().VerboseFocusOn == getFunctionName()); (getContext()->getFlags().VerboseFocusOn == getFunctionName());
if (VerboseFocus) if (VerboseFocus)
......
...@@ -393,6 +393,7 @@ void CfgNode::livenessPostprocess(LivenessMode Mode, Liveness *Liveness) { ...@@ -393,6 +393,7 @@ void CfgNode::livenessPostprocess(LivenessMode Mode, Liveness *Liveness) {
} }
if (Mode != Liveness_Intervals) if (Mode != Liveness_Intervals)
return; return;
TimerMarker T1(TimerStack::TT_liveRangeCtor, Func);
SizeT NumVars = Liveness->getNumVarsInNode(this); SizeT NumVars = Liveness->getNumVarsInNode(this);
SizeT NumGlobals = Liveness->getNumGlobalVars(); SizeT NumGlobals = Liveness->getNumGlobalVars();
......
...@@ -407,6 +407,17 @@ void GlobalContext::popTimer(TimerIdT ID, TimerStackIdT StackID) { ...@@ -407,6 +407,17 @@ void GlobalContext::popTimer(TimerIdT ID, TimerStackIdT StackID) {
Timers[StackID].pop(ID); 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) { void GlobalContext::dumpStats(const IceString &Name, bool Final) {
if (Flags.DumpStats) { if (Flags.DumpStats) {
if (Final) { if (Final) {
......
...@@ -164,6 +164,8 @@ public: ...@@ -164,6 +164,8 @@ public:
TimerStackIdT newTimerStackID(const IceString &Name); TimerStackIdT newTimerStackID(const IceString &Name);
void pushTimer(TimerIdT ID, TimerStackIdT StackID = TSK_Default); void pushTimer(TimerIdT ID, TimerStackIdT StackID = TSK_Default);
void popTimer(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, void dumpTimers(TimerStackIdT StackID = TSK_Default,
bool DumpCumulative = true); bool DumpCumulative = true);
......
...@@ -97,6 +97,15 @@ void TimerStack::update() { ...@@ -97,6 +97,15 @@ void TimerStack::update() {
} }
} }
void TimerStack::reset() {
StateChangeCount = 0;
FirstTimestamp = LastTimestamp = timestamp();
LeafTimes.assign(LeafTimes.size(), 0);
for (TimerTreeNode &Node : Nodes) {
Node.Time = 0;
}
}
namespace { namespace {
typedef std::multimap<double, IceString> DumpMapType; typedef std::multimap<double, IceString> DumpMapType;
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
X(initUnhandled) \ X(initUnhandled) \
X(linearScan) \ X(linearScan) \
X(liveRange) \ X(liveRange) \
X(liveRangeCtor) \
X(liveness) \ X(liveness) \
X(livenessLightweight) \ X(livenessLightweight) \
X(llvmConvert) \ X(llvmConvert) \
......
...@@ -52,15 +52,17 @@ public: ...@@ -52,15 +52,17 @@ public:
}; };
TimerStack(const IceString &Name); TimerStack(const IceString &Name);
TimerIdT getTimerID(const IceString &Name); TimerIdT getTimerID(const IceString &Name);
void setName(const IceString &NewName) { Name = NewName; }
void push(TimerIdT ID); void push(TimerIdT ID);
void pop(TimerIdT ID); void pop(TimerIdT ID);
void reset();
void dump(Ostream &Str, bool DumpCumulative); void dump(Ostream &Str, bool DumpCumulative);
private: private:
void update(); void update();
static double timestamp(); static double timestamp();
const IceString Name; IceString Name;
const double FirstTimestamp; double FirstTimestamp;
double LastTimestamp; double LastTimestamp;
uint64_t StateChangeCount; uint64_t StateChangeCount;
// IDsIndex maps a symbolic timer name to its integer ID. // IDsIndex maps a symbolic timer name to its integer ID.
......
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