• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -codegenprepare -S | FileCheck %s
2
3target triple = "x86_64-pc-linux-gnu"
4
5; This tests that hot/cold functions get correct section prefix assigned
6
7; CHECK: hot_func{{.*}}!section_prefix ![[HOT_ID:[0-9]+]]
8; The entry is hot
9define void @hot_func() !prof !15 {
10  ret void
11}
12
13; CHECK: hot_call_func{{.*}}!section_prefix ![[HOT_ID]]
14; The sum of 2 callsites are hot
15define void @hot_call_func() !prof !16 {
16  call void @hot_func(), !prof !17
17  call void @hot_func(), !prof !17
18  ret void
19}
20
21; CHECK-NOT: normal_func{{.*}}!section_prefix
22; The sum of all callsites are neither hot or cold
23define void @normal_func() !prof !16 {
24  call void @hot_func(), !prof !17
25  call void @hot_func(), !prof !18
26  call void @hot_func(), !prof !18
27  ret void
28}
29
30; CHECK: cold_func{{.*}}!section_prefix ![[COLD_ID:[0-9]+]]
31; The entry and the callsite are both cold
32define void @cold_func() !prof !16 {
33  call void @hot_func(), !prof !18
34  ret void
35}
36
37; CHECK: ![[HOT_ID]] = !{!"function_section_prefix", !"hot"}
38; CHECK: ![[COLD_ID]] = !{!"function_section_prefix", !"unlikely"}
39!llvm.module.flags = !{!1}
40!1 = !{i32 1, !"ProfileSummary", !2}
41!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
42!3 = !{!"ProfileFormat", !"SampleProfile"}
43!4 = !{!"TotalCount", i64 10000}
44!5 = !{!"MaxCount", i64 1000}
45!6 = !{!"MaxInternalCount", i64 1}
46!7 = !{!"MaxFunctionCount", i64 1000}
47!8 = !{!"NumCounts", i64 3}
48!9 = !{!"NumFunctions", i64 3}
49!10 = !{!"DetailedSummary", !11}
50!11 = !{!12, !13, !14}
51!12 = !{i32 10000, i64 100, i32 1}
52!13 = !{i32 999000, i64 100, i32 1}
53!14 = !{i32 999999, i64 1, i32 2}
54!15 = !{!"function_entry_count", i64 1000}
55!16 = !{!"function_entry_count", i64 1}
56!17 = !{!"branch_weights", i32 80}
57!18 = !{!"branch_weights", i32 1}
58