]> granicus.if.org Git - llvm/commitdiff
[ThinLTO] PrintStatistics when we exit early for thinlto-index-only
authorTeresa Johnson <tejohnson@google.com>
Thu, 2 Feb 2017 17:33:53 +0000 (17:33 +0000)
committerTeresa Johnson <tejohnson@google.com>
Thu, 2 Feb 2017 17:33:53 +0000 (17:33 +0000)
Summary:
This is necessary to get stats from the ThinLink printed before the
early exit when compiling in a distributed build.

Reviewers: mehdi_amini

Subscribers: Prazek, llvm-commits

Differential Revision: https://reviews.llvm.org/D29461

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293908 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/gold/X86/stats.ll
tools/gold/gold-plugin.cpp

index 15aa080d6fc0225c06935949fce94c7885ee3bf0..255a2bd90bcdc61ac98e2e57d9c7efc7588d3bbe 100644 (file)
@@ -5,6 +5,13 @@
 ; RUN:    -m elf_x86_64 \
 ; RUN:    -plugin-opt=-stats %t.o -o %t2 2>&1 | FileCheck %s
 
+; RUN: llvm-as %s -o %t.o
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so  -shared \
+; RUN:    -m elf_x86_64 \
+; RUN:    -plugin-opt=thinlto \
+; RUN:    -plugin-opt=thinlto-index-only \
+; RUN:    -plugin-opt=-stats %t.o -o %t2 2>&1 | FileCheck %s
+
 ; CHECK: Statistics Collected
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
index f8e708076131ffe69fd2afb0ffd2c2a012f363b7..cfcb4b953710975c8dd2900ac88d3bcd2cb75fd4 100644 (file)
@@ -12,6 +12,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm/ADT/Statistic.h"
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
 #include "llvm/CodeGen/CommandFlags.h"
@@ -844,6 +845,8 @@ static ld_plugin_status allSymbolsReadHook() {
     return LDPS_OK;
 
   if (options::thinlto_index_only) {
+    if (llvm::AreStatisticsEnabled())
+      llvm::PrintStatistics();
     cleanup_hook();
     exit(0);
   }