llvm.org GIT mirror llvm / 61d9a69
[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 Teresa Johnson 2 years ago
3 changed file(s) with 14 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
12251225 lto::setupOptimizationRemarks(LLVMContext &Context,
12261226 StringRef LTORemarksFilename,
12271227 bool LTOPassRemarksWithHotness, int Count) {
1228 if (LTOPassRemarksWithHotness)
1229 Context.setDiagnosticsHotnessRequested(true);
12281230 if (LTORemarksFilename.empty())
12291231 return nullptr;
12301232
12391241 return errorCodeToError(EC);
12401242 Context.setDiagnosticsOutputFile(
12411243 llvm::make_unique(DiagnosticFile->os()));
1242 if (LTOPassRemarksWithHotness)
1243 Context.setDiagnosticsHotnessRequested(true);
12441244 DiagnosticFile->keep();
12451245 return std::move(DiagnosticFile);
12461246 }
0 ; RUN: llvm-as < %s >%t.bc
11
2 ; Check pass remarks emitted to YAML file
23 ; RUN: rm -f %t.yaml
34 ; RUN: llvm-lto2 run -pass-remarks-output=%t.yaml \
45 ; RUN: -pass-remarks-with-hotness \
67 ; RUN: -r %t.bc,patatino,px \
78 ; RUN: -r %t.bc,main,px -o %t.o %t.bc
89 ; RUN: cat %t.yaml | FileCheck %s -check-prefix=YAML
10
11 ; Check pass remarks emitted to stderr
12 ; RUN: llvm-lto2 run -pass-remarks=inline \
13 ; RUN: -pass-remarks-with-hotness \
14 ; RUN: -r %t.bc,tinkywinky,p \
15 ; RUN: -r %t.bc,patatino,px \
16 ; RUN: -r %t.bc,main,px -o %t.o %t.bc 2>&1 | FileCheck %s
917
1018 ; YAML: --- !Passed
1119 ; YAML-NEXT: Pass: inline
2331 ; YAML-NEXT: - String: ')'
2432 ; YAML-NEXT: ...
2533
34 ; CHECK: tinkywinky inlined into main with cost=-15000 (threshold=337) (hotness: 300)
35
2636 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
2737 target triple = "x86_64-scei-ps4"
2838
191191 DiagnosticPrinterRawOStream DP(errs());
192192 DI.print(DP);
193193 errs() << '\n';
194 exit(1);
194 if (DI.getSeverity() == DS_Error)
195 exit(1);
195196 };
196197
197198 Conf.CPU = MCPU;