summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Timer.cpp
diff options
context:
space:
mode:
authorFedor Sergeev <fedor.sergeev@azul.com>2019-03-22 23:11:08 +0000
committerFedor Sergeev <fedor.sergeev@azul.com>2019-03-22 23:11:08 +0000
commitec74378e93febd5414f30cf2e833eb3ce9273717 (patch)
tree3465f8b3e3ef2df73c9b6223042da0741b8c0cdc /llvm/lib/Support/Timer.cpp
parentb0ae52d814d7de99a06c45c8be43db7536434a94 (diff)
downloadbcm5719-llvm-ec74378e93febd5414f30cf2e833eb3ce9273717.tar.gz
bcm5719-llvm-ec74378e93febd5414f30cf2e833eb3ce9273717.zip
[Legacy][TimePasses] allow -time-passes reporting into a custom stream
As a followup to newpm -time-passes fix (D59366), now adding a similar functionality to legacy time-passes. Enhancing llvm::reportAndResetTimings to accept an optional stream for reporting output. By default it still reports into the stream created by CreateInfoOutputFile (-info-output-file). Also fixing to actually reset after printing as declared. Reviewed By: philip.pfaffe Differential Revision: https://reviews.llvm.org/D59416 llvm-svn: 356824
Diffstat (limited to 'llvm/lib/Support/Timer.cpp')
-rw-r--r--llvm/lib/Support/Timer.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp
index 3cf907d7067..2a7ff1eaaf6 100644
--- a/llvm/lib/Support/Timer.cpp
+++ b/llvm/lib/Support/Timer.cpp
@@ -347,7 +347,7 @@ void TimerGroup::PrintQueuedTimers(raw_ostream &OS) {
TimersToPrint.clear();
}
-void TimerGroup::prepareToPrintList() {
+void TimerGroup::prepareToPrintList(bool ResetTime) {
// See if any of our timers were started, if so add them to TimersToPrint.
for (Timer *T = FirstTimer; T; T = T->Next) {
if (!T->hasTriggered()) continue;
@@ -357,15 +357,20 @@ void TimerGroup::prepareToPrintList() {
TimersToPrint.emplace_back(T->Time, T->Name, T->Description);
+ if (ResetTime)
+ T->clear();
+
if (WasRunning)
T->startTimer();
}
}
-void TimerGroup::print(raw_ostream &OS) {
- sys::SmartScopedLock<true> L(*TimerLock);
-
- prepareToPrintList();
+void TimerGroup::print(raw_ostream &OS, bool ResetAfterPrint) {
+ {
+ // After preparing the timers we can free the lock
+ sys::SmartScopedLock<true> L(*TimerLock);
+ prepareToPrintList(ResetAfterPrint);
+ }
// If any timers were started, print the group.
if (!TimersToPrint.empty())
@@ -405,7 +410,7 @@ void TimerGroup::printJSONValue(raw_ostream &OS, const PrintRecord &R,
const char *TimerGroup::printJSONValues(raw_ostream &OS, const char *delim) {
sys::SmartScopedLock<true> L(*TimerLock);
- prepareToPrintList();
+ prepareToPrintList(false);
for (const PrintRecord &R : TimersToPrint) {
OS << delim;
delim = ",\n";
OpenPOWER on IntegriCloud