From 12585b0148a104dad35feed91f440836b2a97623 Mon Sep 17 00:00:00 2001 From: Easwaran Raman Date: Fri, 20 Jan 2017 22:44:04 +0000 Subject: Improve PGO support for the new inliner This adds the following to the new PM based inliner in PGO mode: * Use block frequency analysis to derive callsite's profile count and use that to adjust thresholds of hot and cold callsites. * Incrementally update the BFI of the caller after a callee gets inlined into it. This incremental update is only within an invocation of the run method - BFI is not preserved across calls to run. Update the function entry count of the callee after inlining it into a caller. * I've tuned the thresholds for the hot and cold callsites using a hacked up version of the old inliner that explicitly computes BFI on a set of internal benchmarks and spec. Once the new PM based pipeline stabilizes (IIRC Chandler mentioned there are known issues) I'll benchmark this again and adjust the thresholds if required. Inliner PGO support. Differential revision: https://reviews.llvm.org/D28331 llvm-svn: 292666 --- .../Transforms/Inline/function-count-update-2.ll | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 llvm/test/Transforms/Inline/function-count-update-2.ll (limited to 'llvm/test/Transforms/Inline/function-count-update-2.ll') diff --git a/llvm/test/Transforms/Inline/function-count-update-2.ll b/llvm/test/Transforms/Inline/function-count-update-2.ll new file mode 100644 index 00000000000..702fa6292c2 --- /dev/null +++ b/llvm/test/Transforms/Inline/function-count-update-2.ll @@ -0,0 +1,33 @@ +; RUN: opt < %s -passes='require,cgscc(inline)' -S | FileCheck %s + +; This tests that the function count of a callee gets correctly updated after it +; has been inlined into a two callsites. + +; CHECK: @callee() !prof [[COUNT:![0-9]+]] +define i32 @callee() !prof !1 { + ret i32 0 +} + +define i32 @caller1() !prof !2 { +; CHECK-LABEL: @caller1 +; CHECK-NOT: callee +; CHECK: ret + %i = call i32 @callee() + ret i32 %i +} + +define i32 @caller2() !prof !3 { +; CHECK-LABEL: @caller2 +; CHECK-NOT: callee +; CHECK: ret + %i = call i32 @callee() + ret i32 %i +} + +!llvm.module.flags = !{!0} +; CHECK: [[COUNT]] = !{!"function_entry_count", i64 0} +!0 = !{i32 1, !"MaxFunctionCount", i32 1000} +!1 = !{!"function_entry_count", i64 1000} +!2 = !{!"function_entry_count", i64 600} +!3 = !{!"function_entry_count", i64 400} + -- cgit v1.2.3