[PATCH] D32803: [LTO] Print time-passes information at conclusion of LTO codegen
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 3 06:40:46 PDT 2017
jhenderson created this revision.
Herald added a subscriber: inglorion.
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 changes 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. Any suggestions would be appreciated.
https://reviews.llvm.org/D32803
Files:
include/llvm/IR/LegacyPassManager.h
lib/IR/LegacyPassManager.cpp
lib/LTO/LTOCodeGenerator.cpp
lib/LTO/ThinLTOCodeGenerator.cpp
Index: lib/LTO/ThinLTOCodeGenerator.cpp
===================================================================
--- lib/LTO/ThinLTOCodeGenerator.cpp
+++ lib/LTO/ThinLTOCodeGenerator.cpp
@@ -1023,4 +1023,5 @@
// If statistics were requested, print them out now.
if (llvm::AreStatisticsEnabled())
llvm::PrintStatistics();
+ reportTimings();
}
Index: lib/LTO/LTOCodeGenerator.cpp
===================================================================
--- lib/LTO/LTOCodeGenerator.cpp
+++ lib/LTO/LTOCodeGenerator.cpp
@@ -600,6 +600,7 @@
// If statistics were requested, print them out after codegen.
if (llvm::AreStatisticsEnabled())
llvm::PrintStatistics();
+ reportTimings();
finishOptimizationRemarks();
Index: lib/IR/LegacyPassManager.cpp
===================================================================
--- lib/IR/LegacyPassManager.cpp
+++ 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 @@
// 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,15 @@
return nullptr;
}
+/// If timing is enabled, report the times collected up to now and then reset
+/// them.
+void llvm::reportTimings() {
+ if (!TimePassesIsEnabled || TheTimeInfo == nullptr)
+ return;
+
+ TheTimeInfo->print();
+}
+
//===----------------------------------------------------------------------===//
// PMStack implementation
//
Index: include/llvm/IR/LegacyPassManager.h
===================================================================
--- include/llvm/IR/LegacyPassManager.h
+++ include/llvm/IR/LegacyPassManager.h
@@ -98,6 +98,7 @@
// Create wrappers for C Binding types (see CBindingWrapping.h).
DEFINE_STDCXX_CONVERSION_FUNCTIONS(legacy::PassManagerBase, LLVMPassManagerRef)
+void reportTimings();
} // End llvm namespace
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32803.97619.patch
Type: text/x-patch
Size: 2424 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170503/1aa47a65/attachment.bin>
More information about the llvm-commits
mailing list