mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[LTOs] Allow generation of hotness information
The flag is passed by the clang driver. Differential Revision: https://reviews.llvm.org/D27331 llvm-svn: 288519
This commit is contained in:
parent
f4d1e7a9ab
commit
dd0da943ed
@ -96,6 +96,11 @@ cl::opt<std::string>
|
||||
LTORemarksFilename("lto-pass-remarks-output",
|
||||
cl::desc("Output filename for pass remarks"),
|
||||
cl::value_desc("filename"));
|
||||
|
||||
cl::opt<bool> LTOPassRemarksWithHotness(
|
||||
"lto-pass-remarks-with-hotness",
|
||||
cl::desc("With PGO, include profile count in optimization remarks"),
|
||||
cl::Hidden);
|
||||
}
|
||||
|
||||
LTOCodeGenerator::LTOCodeGenerator(LLVMContext &Context)
|
||||
@ -513,6 +518,10 @@ bool LTOCodeGenerator::setupOptimizationRemarks() {
|
||||
Context.setDiagnosticsOutputFile(
|
||||
llvm::make_unique<yaml::Output>(DiagnosticOutputFile->os()));
|
||||
}
|
||||
|
||||
if (LTOPassRemarksWithHotness)
|
||||
Context.setDiagnosticHotnessRequested(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,7 @@ namespace llvm {
|
||||
// Flags -discard-value-names, defined in LTOCodeGenerator.cpp
|
||||
extern cl::opt<bool> LTODiscardValueNames;
|
||||
extern cl::opt<std::string> LTORemarksFilename;
|
||||
extern cl::opt<bool> LTOPassRemarksWithHotness;
|
||||
}
|
||||
|
||||
namespace {
|
||||
@ -74,6 +75,9 @@ static cl::opt<int>
|
||||
|
||||
Expected<std::unique_ptr<tool_output_file>>
|
||||
setupOptimizationRemarks(LLVMContext &Ctx, int Count) {
|
||||
if (LTOPassRemarksWithHotness)
|
||||
Ctx.setDiagnosticHotnessRequested(true);
|
||||
|
||||
if (LTORemarksFilename.empty())
|
||||
return nullptr;
|
||||
|
||||
|
77
test/LTO/X86/diagnostic-handler-remarks-with-hotness.ll
Normal file
77
test/LTO/X86/diagnostic-handler-remarks-with-hotness.ll
Normal file
@ -0,0 +1,77 @@
|
||||
; Check that the hotness attribute is included in the optimization record file
|
||||
; with -lto-pass-remarks-with-hotness.
|
||||
|
||||
; RUN: llvm-as < %s >%t.bc
|
||||
; RUN: llvm-lto -lto-pass-remarks-output=%t.yaml \
|
||||
; RUN: -lto-pass-remarks-with-hotness \
|
||||
; RUN: -exported-symbol _func2 \
|
||||
; RUN: -exported-symbol _main -o %t.o %t.bc
|
||||
; RUN: cat %t.yaml | FileCheck -check-prefix=YAML %s
|
||||
|
||||
; YAML: --- !Passed
|
||||
; YAML-NEXT: Pass: inline
|
||||
; YAML-NEXT: Name: Inlined
|
||||
; YAML-NEXT: Function: main
|
||||
; YAML-NEXT: Hotness: 300
|
||||
; YAML-NEXT: Args:
|
||||
; YAML-NEXT: - Callee: foo
|
||||
; YAML-NEXT: - String: ' inlined into '
|
||||
; YAML-NEXT: - Caller: main
|
||||
; YAML-NEXT: ...
|
||||
|
||||
target triple = "x86_64-apple-darwin"
|
||||
|
||||
declare i32 @bar()
|
||||
|
||||
define i32 @foo() {
|
||||
%a = call i32 @bar()
|
||||
ret i32 %a
|
||||
}
|
||||
|
||||
define i32 @main() !prof !0 {
|
||||
%i = call i32 @foo()
|
||||
ret i32 %i
|
||||
}
|
||||
|
||||
define i32 @func2(i32* %out, i32* %out2, i32* %A, i32* %B, i32* %C, i32* %D, i32* %E, i32* %F) {
|
||||
entry:
|
||||
br label %for.body
|
||||
|
||||
for.body: ; preds = %for.body, %entry
|
||||
%i.037 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
|
||||
%arrayidx = getelementptr inbounds i32, i32* %A, i64 %i.037
|
||||
%0 = load i32, i32* %arrayidx, align 4
|
||||
%arrayidx1 = getelementptr inbounds i32, i32* %B, i64 %i.037
|
||||
%1 = load i32, i32* %arrayidx1, align 4
|
||||
%add = add nsw i32 %1, %0
|
||||
%arrayidx2 = getelementptr inbounds i32, i32* %C, i64 %i.037
|
||||
%2 = load i32, i32* %arrayidx2, align 4
|
||||
%add3 = add nsw i32 %add, %2
|
||||
%arrayidx4 = getelementptr inbounds i32, i32* %E, i64 %i.037
|
||||
%3 = load i32, i32* %arrayidx4, align 4
|
||||
%add5 = add nsw i32 %add3, %3
|
||||
%arrayidx6 = getelementptr inbounds i32, i32* %F, i64 %i.037
|
||||
%4 = load i32, i32* %arrayidx6, align 4
|
||||
%add7 = add nsw i32 %add5, %4
|
||||
%arrayidx8 = getelementptr inbounds i32, i32* %out, i64 %i.037
|
||||
store i32 %add7, i32* %arrayidx8, align 4
|
||||
%5 = load i32, i32* %arrayidx, align 4
|
||||
%6 = load i32, i32* %arrayidx1, align 4
|
||||
%add11 = add nsw i32 %6, %5
|
||||
%7 = load i32, i32* %arrayidx2, align 4
|
||||
%add13 = add nsw i32 %add11, %7
|
||||
%8 = load i32, i32* %arrayidx4, align 4
|
||||
%add15 = add nsw i32 %add13, %8
|
||||
%9 = load i32, i32* %arrayidx6, align 4
|
||||
%add17 = add nsw i32 %add15, %9
|
||||
%arrayidx18 = getelementptr inbounds i32, i32* %out2, i64 %i.037
|
||||
store i32 %add17, i32* %arrayidx18, align 4
|
||||
%inc = add i64 %i.037, 1
|
||||
%exitcond = icmp eq i64 %inc, 256
|
||||
br i1 %exitcond, label %for.end, label %for.body
|
||||
|
||||
for.end: ; preds = %for.body
|
||||
ret i32 undef
|
||||
}
|
||||
|
||||
!0 = !{!"function_entry_count", i64 300}
|
56
test/ThinLTO/X86/diagnostic-handler-remarks-with-hotness.ll
Normal file
56
test/ThinLTO/X86/diagnostic-handler-remarks-with-hotness.ll
Normal file
@ -0,0 +1,56 @@
|
||||
; RUN: opt -module-summary %s -o %t1.bc
|
||||
; RUN: opt -module-summary %p/Inputs/diagnostic-handler-remarks.ll -o %t2.bc
|
||||
|
||||
; Check that the hotness attribute is included in the optimization record file
|
||||
; with -lto-pass-remarks-with-hotness.
|
||||
|
||||
; RUN: llvm-lto -thinlto-action=run \
|
||||
; RUN: -lto-pass-remarks-output=%t.yaml \
|
||||
; RUN: -lto-pass-remarks-with-hotness \
|
||||
; RUN: -exported-symbol _func2 \
|
||||
; RUN: -exported-symbol _main %t1.bc %t2.bc 2>&1 | \
|
||||
; RUN: FileCheck %s -allow-empty
|
||||
; CHECK-NOT: remark:
|
||||
; CHECK-NOT: llvm-lto:
|
||||
|
||||
|
||||
; Verify that bar is imported and inlined into foo
|
||||
; RUN: cat %t.yaml.thin.0.yaml | FileCheck %s -check-prefix=YAML1
|
||||
; YAML1: --- !Passed
|
||||
; YAML1-NEXT: Pass: inline
|
||||
; YAML1-NEXT: Name: Inlined
|
||||
; YAML1-NEXT: Function: main
|
||||
; YAML1-NEXT: Hotness: 50
|
||||
; YAML1-NEXT: Args:
|
||||
; YAML1-NEXT: - Callee: foo
|
||||
; YAML1-NEXT: - String: ' inlined into '
|
||||
; YAML1-NEXT: - Caller: main
|
||||
; YAML1-NEXT: ...
|
||||
|
||||
|
||||
; Verify that bar is imported and inlined into foo
|
||||
; RUN: cat %t.yaml.thin.1.yaml | FileCheck %s -check-prefix=YAML2
|
||||
; YAML2: --- !Passed
|
||||
; YAML2-NEXT: Pass: inline
|
||||
; YAML2-NEXT: Name: Inlined
|
||||
; YAML2-NEXT: Function: foo
|
||||
; YAML2-NEXT: Args:
|
||||
; YAML2-NEXT: - Callee: bar
|
||||
; YAML2-NEXT: - String: ' inlined into '
|
||||
; YAML2-NEXT: - Caller: foo
|
||||
; YAML2-NEXT: ...
|
||||
|
||||
|
||||
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-apple-macosx10.11.0"
|
||||
|
||||
define i32 @bar() {
|
||||
ret i32 42
|
||||
}
|
||||
declare i32 @foo()
|
||||
define i32 @main() !prof !0 {
|
||||
%i = call i32 @foo()
|
||||
ret i32 %i
|
||||
}
|
||||
|
||||
!0 = !{!"function_entry_count", i64 50}
|
Loading…
x
Reference in New Issue
Block a user