aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2018-05-04 23:59:34 +0000
committerTeresa Johnson <tejohnson@google.com>2018-05-04 23:59:34 +0000
commit61d9a69a186d882eca84843a054ed8db5c1058ff (patch)
tree3358a715891558129939a3517e0eea5512152211
parent62b8986cc32ed22106c7776966782da50ea3f528 (diff)
[LTO] Allow pass remarks with hotness to be set when emitting to stderr
Summary: Set setDiagnosticsHotnessRequested before the early exit check for a diagnostic output file, so that pass remarks with hotness works when emitting pass remarks to stderr (e.g. via -pass-remarks=.). Also fix the llvm-lto2 diagnistic handler so that it only calls exit(1) when the diagnistic is an error type. Otherwise the new test invocation of llvm-lto2 with -pass-remarks causes it to fail. The new code is consistent with the diagnostic handler elsewhere (e.g. on the LLVMContext). Reviewers: pcc, davide Subscribers: fhahn, mehdi_amini, llvm-commits, inglorion Differential Revision: https://reviews.llvm.org/D46387 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331569 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/LTO/LTO.cpp4
-rw-r--r--test/LTO/Resolution/X86/diagnostic-handler-remarks-with-hotness.ll10
-rw-r--r--tools/llvm-lto2/llvm-lto2.cpp3
3 files changed, 14 insertions, 3 deletions
diff --git a/lib/LTO/LTO.cpp b/lib/LTO/LTO.cpp
index 7e8b9b3c639..c74a7b39466 100644
--- a/lib/LTO/LTO.cpp
+++ b/lib/LTO/LTO.cpp
@@ -1226,6 +1226,8 @@ Expected<std::unique_ptr<ToolOutputFile>>
lto::setupOptimizationRemarks(LLVMContext &Context,
StringRef LTORemarksFilename,
bool LTOPassRemarksWithHotness, int Count) {
+ if (LTOPassRemarksWithHotness)
+ Context.setDiagnosticsHotnessRequested(true);
if (LTORemarksFilename.empty())
return nullptr;
@@ -1240,8 +1242,6 @@ lto::setupOptimizationRemarks(LLVMContext &Context,
return errorCodeToError(EC);
Context.setDiagnosticsOutputFile(
llvm::make_unique<yaml::Output>(DiagnosticFile->os()));
- if (LTOPassRemarksWithHotness)
- Context.setDiagnosticsHotnessRequested(true);
DiagnosticFile->keep();
return std::move(DiagnosticFile);
}
diff --git a/test/LTO/Resolution/X86/diagnostic-handler-remarks-with-hotness.ll b/test/LTO/Resolution/X86/diagnostic-handler-remarks-with-hotness.ll
index 2daba928e7e..c45dd4bcd0e 100644
--- a/test/LTO/Resolution/X86/diagnostic-handler-remarks-with-hotness.ll
+++ b/test/LTO/Resolution/X86/diagnostic-handler-remarks-with-hotness.ll
@@ -1,5 +1,6 @@
; RUN: llvm-as < %s >%t.bc
+; Check pass remarks emitted to YAML file
; RUN: rm -f %t.yaml
; RUN: llvm-lto2 run -pass-remarks-output=%t.yaml \
; RUN: -pass-remarks-with-hotness \
@@ -8,6 +9,13 @@
; RUN: -r %t.bc,main,px -o %t.o %t.bc
; RUN: cat %t.yaml | FileCheck %s -check-prefix=YAML
+; Check pass remarks emitted to stderr
+; RUN: llvm-lto2 run -pass-remarks=inline \
+; RUN: -pass-remarks-with-hotness \
+; RUN: -r %t.bc,tinkywinky,p \
+; RUN: -r %t.bc,patatino,px \
+; RUN: -r %t.bc,main,px -o %t.o %t.bc 2>&1 | FileCheck %s
+
; YAML: --- !Passed
; YAML-NEXT: Pass: inline
; YAML-NEXT: Name: Inlined
@@ -24,6 +32,8 @@
; YAML-NEXT: - String: ')'
; YAML-NEXT: ...
+; CHECK: tinkywinky inlined into main with cost=-15000 (threshold=337) (hotness: 300)
+
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-scei-ps4"
diff --git a/tools/llvm-lto2/llvm-lto2.cpp b/tools/llvm-lto2/llvm-lto2.cpp
index aab0f6f303a..442973f9020 100644
--- a/tools/llvm-lto2/llvm-lto2.cpp
+++ b/tools/llvm-lto2/llvm-lto2.cpp
@@ -192,7 +192,8 @@ static int run(int argc, char **argv) {
DiagnosticPrinterRawOStream DP(errs());
DI.print(DP);
errs() << '\n';
- exit(1);
+ if (DI.getSeverity() == DS_Error)
+ exit(1);
};
Conf.CPU = MCPU;