blob: 7e43adb905efc6da97accf42ca1adca937333b6d [file] [log] [blame]
Dehao Chen77079002017-01-20 22:56:07 +00001; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/indirect-call.prof -S | FileCheck %s
2
Dehao Chen274df5e2017-01-31 17:49:37 +00003; CHECK-LABEL: @test
Dehao Chen77079002017-01-20 22:56:07 +00004define void @test(void ()*) !dbg !3 {
5 %2 = alloca void ()*
6 store void ()* %0, void ()** %2
7 %3 = load void ()*, void ()** %2
8 ; CHECK: call {{.*}}, !prof ![[PROF:[0-9]+]]
9 call void %3(), !dbg !4
10 ret void
11}
12
Dehao Chen274df5e2017-01-31 17:49:37 +000013; CHECK-LABEL: @test_inline
14; If the indirect call is promoted and inlined in profile, we should promote and inline it.
15define void @test_inline(void ()*) !dbg !3 {
16 %2 = alloca void ()*
17 store void ()* %0, void ()** %2
18 %3 = load void ()*, void ()** %2
19; CHECK: icmp {{.*}} @foo_inline
20; CHECK: if.true.direct_targ:
21; CHECK-NOT: call
22; CHECK: if.false.orig_indirect:
23; CHECK: call
24 call void %3(), !dbg !5
25 ret void
26}
27
28; CHECK-LABEL: @test_noinline
29; If the indirect call target is not available, we should not promote it.
30define void @test_noinline(void ()*) !dbg !3 {
31 %2 = alloca void ()*
32 store void ()* %0, void ()** %2
33 %3 = load void ()*, void ()** %2
34; CHECK-NOT: icmp
35; CHECK: call
36 call void %3(), !dbg !5
37 ret void
38}
39
40define void @foo_inline() !dbg !3 {
41 ret void
42}
43
44define i32 @foo_noinline(i32 %x) !dbg !3 {
45 ret i32 %x
46}
47
Dehao Chen77079002017-01-20 22:56:07 +000048!llvm.dbg.cu = !{!0}
49!llvm.module.flags = !{!2}
50
51!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1)
52!1 = !DIFile(filename: "test.cc", directory: "/")
53!2 = !{i32 2, !"Debug Info Version", i32 3}
54!3 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 1, unit: !0)
55!4 = !DILocation(line: 5, scope: !3)
Dehao Chen274df5e2017-01-31 17:49:37 +000056!5 = !DILocation(line: 6, scope: !3)
Dehao Chen77079002017-01-20 22:56:07 +000057; CHECK: ![[PROF]] = !{!"VP", i32 0, i64 3457, i64 9191153033785521275, i64 2059, i64 -1069303473483922844, i64 1398}