1; REQUIRES: x86-registered-target
2; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/inline.prof -codegenprepare -S | FileCheck %s
3; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/inline.prof -codegenprepare -profile-unknown-in-special-section -partial-profile -S | FileCheck %s --check-prefix UNKNOWN
4; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/inline.prof -codegenprepare -profile-sample-accurate -S | FileCheck %s --check-prefix ACCURATE
5
6target triple = "x86_64-pc-linux-gnu"
7
8; The test checks that function without profile gets unlikely section prefix
9; if -profile-sample-accurate is specified or the function has the
10; profile-sample-accurate attribute.
11
12declare void @hot_func()
13
14; CHECK-NOT: foo_not_in_profile{{.*}}!section_prefix
15; CHECK: foo_not_in_profile{{.*}}!prof ![[NOPROFILE_ID:[0-9]+]]
16; UNKNOWN: foo_not_in_profile{{.*}}!prof ![[NOPROFILE_ID:[0-9]+]] !section_prefix ![[UNKNOWN_ID:[0-9]+]]
17; ACCURATE: foo_not_in_profile{{.*}}!prof ![[ZERO_ID:[0-9]+]] !section_prefix ![[COLD_ID:[0-9]+]]
18; The function not appearing in profile is cold when -profile-sample-accurate
19; is on.
20define void @foo_not_in_profile() #1 {
21  call void @hot_func()
22  ret void
23}
24
25; CHECK: bar_not_in_profile{{.*}}!prof ![[ZERO_ID:[0-9]+]] !section_prefix ![[COLD_ID:[0-9]+]]
26; ACCURATE: bar_not_in_profile{{.*}}!prof ![[ZERO_ID:[0-9]+]] !section_prefix ![[COLD_ID:[0-9]+]]
27; The function not appearing in profile is cold when the func has
28; profile-sample-accurate attribute.
29define void @bar_not_in_profile() #0 {
30  call void @hot_func()
31  ret void
32}
33
34attributes #0 = { "profile-sample-accurate" "use-sample-profile" }
35attributes #1 = { "use-sample-profile" }
36
37; CHECK: ![[NOPROFILE_ID]] = !{!"function_entry_count", i64 -1}
38; CHECK: ![[ZERO_ID]] = !{!"function_entry_count", i64 0}
39; CHECK: ![[COLD_ID]] = !{!"function_section_prefix", !"unlikely"}
40; UNKNOWN: ![[NOPROFILE_ID]] = !{!"function_entry_count", i64 -1}
41; UNKNOWN: ![[UNKNOWN_ID]] = !{!"function_section_prefix", !"unknown"}
42; ACCURATE: ![[ZERO_ID]] = !{!"function_entry_count", i64 0}
43; ACCURATE: ![[COLD_ID]] = !{!"function_section_prefix", !"unlikely"}
44!llvm.module.flags = !{!1}
45!1 = !{i32 1, !"ProfileSummary", !2}
46!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
47!3 = !{!"ProfileFormat", !"SampleProfile"}
48!4 = !{!"TotalCount", i64 10000}
49!5 = !{!"MaxCount", i64 1000}
50!6 = !{!"MaxInternalCount", i64 1}
51!7 = !{!"MaxFunctionCount", i64 1000}
52!8 = !{!"NumCounts", i64 3}
53!9 = !{!"NumFunctions", i64 3}
54!10 = !{!"DetailedSummary", !11}
55!11 = !{!12, !13, !14}
56!12 = !{i32 10000, i64 100, i32 1}
57!13 = !{i32 999000, i64 100, i32 1}
58!14 = !{i32 999999, i64 1, i32 2}
59