diff options
author | James Henderson <jh7370@my.bristol.ac.uk> | 2017-05-16 09:43:21 +0000 |
---|---|---|
committer | James Henderson <jh7370@my.bristol.ac.uk> | 2017-05-16 09:43:21 +0000 |
commit | 97f3849c4f602e7f1174a4cd51a07e9ffab9dd4b (patch) | |
tree | b85793af04f8f879ae28d058ae21e3dbf96a9ab3 /lib/IR/LegacyPassManager.cpp | |
parent | e413590ae24728862a4b277d67485bce7e190301 (diff) |
[LTO] Print time-passes information at conclusion of LTO codegen
The information collected when requested by -time-passes is only printed when
llvm_shutdown is called at the moment. This means that when linking against the LTO
library dynamically and using the C interface, it is not possible to see the timing
information, because llvm_shutdown cannot be called. This change modifies the LTO
code generation functions for both regular LTO and thin LTO to explicitly print and
reset the timing information.
I have tested that this works with our proprietary linker. However, as this relies
on a specific method of building and linking against the LTO library, I'm not sure
how or if this can be tested in the LLVM testsuite.
Reviewed by: mehdi_amini
Differential Revision: https://reviews.llvm.org/D32803
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303152 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/LegacyPassManager.cpp')
-rw-r--r-- | lib/IR/LegacyPassManager.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/IR/LegacyPassManager.cpp b/lib/IR/LegacyPassManager.cpp index 628a67bd639..b2b12289f87 100644 --- a/lib/IR/LegacyPassManager.cpp +++ b/lib/IR/LegacyPassManager.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/IR/LegacyPassManager.h" +#include "llvm/ADT/Statistic.h" #include "llvm/IR/IRPrintingPasses.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/LegacyPassManagers.h" @@ -465,6 +466,11 @@ public: // null. It may be called multiple times. static void createTheTimeInfo(); + // print - Prints out timing information and then resets the timers. + void print() { + TG.print(*CreateInfoOutputFile()); + } + /// getPassTimer - Return the timer for the specified pass if it exists. Timer *getPassTimer(Pass *P) { if (P->getAsPMDataManager()) @@ -1752,6 +1758,13 @@ Timer *llvm::getPassTimer(Pass *P) { return nullptr; } +/// If timing is enabled, report the times collected up to now and then reset +/// them. +void llvm::reportAndResetTimings() { + if (TheTimeInfo) + TheTimeInfo->print(); +} + //===----------------------------------------------------------------------===// // PMStack implementation // |