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() {
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)
......
......@@ -393,6 +393,7 @@ void CfgNode::livenessPostprocess(LivenessMode Mode, Liveness *Liveness) {
}
if (Mode != Liveness_Intervals)
return;
TimerMarker T1(TimerStack::TT_liveRangeCtor, Func);
SizeT NumVars = Liveness->getNumVarsInNode(this);
SizeT NumGlobals = Liveness->getNumGlobalVars();
......
......@@ -407,6 +407,17 @@ void GlobalContext::popTimer(TimerIdT ID, TimerStackIdT StackID) {
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) {
......
......@@ -164,6 +164,8 @@ public:
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);
......
......@@ -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 {
typedef std::multimap<double, IceString> DumpMapType;
......
......@@ -30,6 +30,7 @@
X(initUnhandled) \
X(linearScan) \
X(liveRange) \
X(liveRangeCtor) \
X(liveness) \
X(livenessLightweight) \
X(llvmConvert) \
......
......@@ -52,15 +52,17 @@ public:
};
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.
......
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