[PATCH] D17302: [LTO] Support Statistics

Adam Nemet via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 16 12:09:09 PST 2016


anemet created this revision.
anemet added reviewers: dexonsmith, joker.eph.
anemet added a subscriber: llvm-commits.
Herald added a subscriber: joker.eph.

I thought -Xlinker -mllvm -Xlinker -stats worked at some point but maybe
it never did.

For clang, I believe that stats are printed from cc1_main.  This patch
also prints them for LTO, specifically right after codegen happens.

I only looked at the C API for LTO briefly to see if this is a good
place.  Probably there are still cases where this wouldn't be printed
but it seems to be working for the common case.  I also experimented
putting this in the LTOCodeGenerator destructor but that didn't trigger
for me.

http://reviews.llvm.org/D17302

Files:
  lib/LTO/LTOCodeGenerator.cpp

Index: lib/LTO/LTOCodeGenerator.cpp
===================================================================
--- lib/LTO/LTOCodeGenerator.cpp
+++ lib/LTO/LTOCodeGenerator.cpp
@@ -13,6 +13,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/LTO/LTOCodeGenerator.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Analysis/Passes.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
@@ -553,6 +554,10 @@
                    RelocModel, CodeModel::Default, CGOptLevel, FileType,
                    ShouldRestoreGlobalsLinkage);
 
+  // If statistics were requested, print them out after codegen.
+  if (llvm::AreStatisticsEnabled())
+    llvm::PrintStatistics();
+
   return true;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17302.48094.patch
Type: text/x-patch
Size: 765 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160216/e29d757a/attachment.bin>


More information about the llvm-commits mailing list