summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/PassTimingInfo.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/IR/PassTimingInfo.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/IR/PassTimingInfo.cpp')
-rw-r--r--llvm/lib/IR/PassTimingInfo.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/IR/PassTimingInfo.cpp b/llvm/lib/IR/PassTimingInfo.cpp
index dcbfff1a161..9cc44ea05fe 100644
--- a/llvm/lib/IR/PassTimingInfo.cpp
+++ b/llvm/lib/IR/PassTimingInfo.cpp
@@ -77,7 +77,8 @@ public:
static void init();
/// Prints out timing information and then resets the timers.
- void print();
+ /// By default it uses the stream created by CreateInfoOutputFile().
+ void print(raw_ostream *OutStream = nullptr);
/// Returns the timer for the specified pass if it exists.
Timer *getPassTimer(Pass *, PassInstanceID);
@@ -111,7 +112,9 @@ void PassTimingInfo::init() {
}
/// Prints out timing information and then resets the timers.
-void PassTimingInfo::print() { TG.print(*CreateInfoOutputFile()); }
+void PassTimingInfo::print(raw_ostream *OutStream) {
+ TG.print(OutStream ? *OutStream : *CreateInfoOutputFile(), true);
+}
Timer *PassTimingInfo::newPassTimer(StringRef PassID, StringRef PassDesc) {
unsigned &num = PassIDCountMap[PassID];
@@ -153,9 +156,9 @@ Timer *getPassTimer(Pass *P) {
/// If timing is enabled, report the times collected up to now and then reset
/// them.
-void reportAndResetTimings() {
+void reportAndResetTimings(raw_ostream *OutStream) {
if (legacy::PassTimingInfo::TheTimeInfo)
- legacy::PassTimingInfo::TheTimeInfo->print();
+ legacy::PassTimingInfo::TheTimeInfo->print(OutStream);
}
//===----------------------------------------------------------------------===//
@@ -188,8 +191,7 @@ void TimePassesHandler::setOutStream(raw_ostream &Out) {
void TimePassesHandler::print() {
if (!Enabled)
return;
- TG.print(OutStream ? *OutStream : *CreateInfoOutputFile());
- TG.clear();
+ TG.print(OutStream ? *OutStream : *CreateInfoOutputFile(), true);
}
LLVM_DUMP_METHOD void TimePassesHandler::dump() const {
OpenPOWER on IntegriCloud