1; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/indirect-call-csspgo.prof -sample-profile-icp-relative-hotness=1 -pass-remarks=sample-profile -S -o /dev/null 2>&1 | FileCheck -check-prefix=ICP-ALL %s
2; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/indirect-call-csspgo.prof -sample-profile-icp-relative-hotness=1  -pass-remarks=sample-profile -S -o /dev/null 2>&1 | FileCheck -check-prefix=ICP-ALL %s
3; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/indirect-call-csspgo.prof -sample-profile-icp-relative-hotness=1  -pass-remarks=sample-profile -sample-profile-inline-size=0 -S -o /dev/null 2>&1 | FileCheck -check-prefix=ICP-HOT %s
4; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/indirect-call-csspgo.prof -sample-profile-icp-relative-hotness=1  -pass-remarks=sample-profile -sample-profile-inline-size=0 -S -o /dev/null 2>&1 | FileCheck -check-prefix=ICP-HOT %s
5
6define void @test(void ()*) #0 !dbg !3 {
7;; Add two direct call to force top-down order for sample profile loader
8  call void @_Z3foov(), !dbg !7
9  call void @_Z3barv(), !dbg !7
10  call void @_Z3bazv(), !dbg !7
11  %2 = alloca void ()*
12  store void ()* %0, void ()** %2
13  %3 = load void ()*, void ()** %2
14  call void %3(), !dbg !4
15  %4 = alloca void ()*
16  store void ()* %0, void ()** %4
17  %5 = load void ()*, void ()** %4
18  call void %5(), !dbg !5
19  ret void
20}
21
22define void @_Z3foov() #0 !dbg !8 {
23  ret void
24}
25
26define void @_Z3barv() #0 !dbg !9 {
27  ret void
28}
29
30define void @_Z3bazv() #0 !dbg !10 {
31  ret void
32}
33
34define void @_Z3zoov() #0 !dbg !11 {
35  ret void
36}
37
38attributes #0 = {"use-sample-profile"}
39
40!llvm.dbg.cu = !{!0}
41!llvm.module.flags = !{!2}
42
43!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1)
44!1 = !DIFile(filename: "test.cc", directory: "/")
45!2 = !{i32 2, !"Debug Info Version", i32 3}
46!3 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 3, unit: !0)
47!4 = !DILocation(line: 4, scope: !3)
48!5 = !DILocation(line: 5, scope: !3)
49!6 = !DILocation(line: 6, scope: !3)
50!7 = !DILocation(line: 7, scope: !3)
51!8 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 29, unit: !0)
52!9 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barv", scope: !1, file: !1, line: 32, unit: !0)
53!10 = distinct !DISubprogram(name: "baz", linkageName: "_Z3bazv", scope: !1, file: !1, line: 24, unit: !0)
54!11 = distinct !DISubprogram(name: "zoo", linkageName: "_Z3zoov", scope: !1, file: !1, line: 24, unit: !0)
55
56
57; ICP-ALL: remark: test.cc:5:0: '_Z3bazv' inlined into 'test'
58; ICP-ALL-NEXT: remark: test.cc:4:0: '_Z3foov' inlined into 'test'
59; ICP-ALL-NEXT: remark: test.cc:4:0: '_Z3barv' inlined into 'test'
60; ICP-ALL-NOT: remark
61
62; ICP-HOT: remark: test.cc:4:0: '_Z3foov' inlined into 'test'
63; ICP-HOT-NOT: remark
64