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