summaryrefslogtreecommitdiff
path: root/test/Transforms/SampleProfile
diff options
context:
space:
mode:
authorDehao Chen <dehao@google.com>2017-01-31 17:49:37 +0000
committerDehao Chen <dehao@google.com>2017-01-31 17:49:37 +0000
commit500e57803cb3da2b579c0309598f2578874ae39e (patch)
tree89bc2b9e1c4a0985c4a80dd97e1bf7b7196b6c2a /test/Transforms/SampleProfile
parent076c84001273652d28905786003940e9cbff3e6c (diff)
Explicitly promote indirect calls before sample profile annotation.
Summary: In iterative sample pgo where profile is collected from PGOed binary, we may see indirect call targets promoted and inlined in the profile. Before profile annotation, we need to make this happen in order to annotate correctly on IR. This patch explicitly promotes these indirect calls and inlines them before profile annotation. Reviewers: xur, davidxl Reviewed By: davidxl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29040 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293657 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/SampleProfile')
-rw-r--r--test/Transforms/SampleProfile/Inputs/indirect-call.prof6
-rw-r--r--test/Transforms/SampleProfile/indirect-call.ll37
2 files changed, 43 insertions, 0 deletions
diff --git a/test/Transforms/SampleProfile/Inputs/indirect-call.prof b/test/Transforms/SampleProfile/Inputs/indirect-call.prof
index 534975e6270..9ebfd77147d 100644
--- a/test/Transforms/SampleProfile/Inputs/indirect-call.prof
+++ b/test/Transforms/SampleProfile/Inputs/indirect-call.prof
@@ -1,2 +1,8 @@
test:63067:0
4: 3345 _Z3barv:1398 _Z3foov:2059
+test_inline:3000:0
+ 5: foo_inline:3000
+ 1: 3000
+test_noinline:3000:0
+ 5: foo_noinline:3000
+ 1: 3000
diff --git a/test/Transforms/SampleProfile/indirect-call.ll b/test/Transforms/SampleProfile/indirect-call.ll
index 01192d80e94..7e43adb905e 100644
--- a/test/Transforms/SampleProfile/indirect-call.ll
+++ b/test/Transforms/SampleProfile/indirect-call.ll
@@ -1,5 +1,6 @@
; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/indirect-call.prof -S | FileCheck %s
+; CHECK-LABEL: @test
define void @test(void ()*) !dbg !3 {
%2 = alloca void ()*
store void ()* %0, void ()** %2
@@ -9,6 +10,41 @@ define void @test(void ()*) !dbg !3 {
ret void
}
+; CHECK-LABEL: @test_inline
+; If the indirect call is promoted and inlined in profile, we should promote and inline it.
+define void @test_inline(void ()*) !dbg !3 {
+ %2 = alloca void ()*
+ store void ()* %0, void ()** %2
+ %3 = load void ()*, void ()** %2
+; CHECK: icmp {{.*}} @foo_inline
+; CHECK: if.true.direct_targ:
+; CHECK-NOT: call
+; CHECK: if.false.orig_indirect:
+; CHECK: call
+ call void %3(), !dbg !5
+ ret void
+}
+
+; CHECK-LABEL: @test_noinline
+; If the indirect call target is not available, we should not promote it.
+define void @test_noinline(void ()*) !dbg !3 {
+ %2 = alloca void ()*
+ store void ()* %0, void ()** %2
+ %3 = load void ()*, void ()** %2
+; CHECK-NOT: icmp
+; CHECK: call
+ call void %3(), !dbg !5
+ ret void
+}
+
+define void @foo_inline() !dbg !3 {
+ ret void
+}
+
+define i32 @foo_noinline(i32 %x) !dbg !3 {
+ ret i32 %x
+}
+
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!2}
@@ -17,4 +53,5 @@ define void @test(void ()*) !dbg !3 {
!2 = !{i32 2, !"Debug Info Version", i32 3}
!3 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 1, unit: !0)
!4 = !DILocation(line: 5, scope: !3)
+!5 = !DILocation(line: 6, scope: !3)
; CHECK: ![[PROF]] = !{!"VP", i32 0, i64 3457, i64 9191153033785521275, i64 2059, i64 -1069303473483922844, i64 1398}