blob: 2c96612e1bafafab82dabba7deea0d6d5e01b4e9 [file] [log] [blame]
Dehao Chen4b415712016-10-19 03:53:41 +00001; RUN: opt < %s -codegenprepare -S | FileCheck %s
Dehao Chen302b69c2016-10-18 20:42:47 +00002
Dehao Chen83033e02016-10-18 21:13:31 +00003target triple = "x86_64-pc-linux-gnu"
4
Dehao Chen302b69c2016-10-18 20:42:47 +00005; This tests that hot/cold functions get correct section prefix assigned
6
Dehao Chen4b415712016-10-19 03:53:41 +00007; CHECK: hot_func{{.*}}!section_prefix ![[HOT_ID:[0-9]+]]
Dehao Chen775341a2017-03-23 23:14:11 +00008; The entry is hot
Dehao Chen302b69c2016-10-18 20:42:47 +00009define void @hot_func() !prof !15 {
10 ret void
11}
12
Dehao Chen775341a2017-03-23 23:14:11 +000013; 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
Dehao Chen4b415712016-10-19 03:53:41 +000030; CHECK: cold_func{{.*}}!section_prefix ![[COLD_ID:[0-9]+]]
Dehao Chen775341a2017-03-23 23:14:11 +000031; The entry and the callsite are both cold
Dehao Chen302b69c2016-10-18 20:42:47 +000032define void @cold_func() !prof !16 {
Dehao Chen775341a2017-03-23 23:14:11 +000033 call void @hot_func(), !prof !18
Dehao Chen302b69c2016-10-18 20:42:47 +000034 ret void
35}
36
Dehao Chen4b415712016-10-19 03:53:41 +000037; CHECK: ![[HOT_ID]] = !{!"function_section_prefix", !".hot"}
38; CHECK: ![[COLD_ID]] = !{!"function_section_prefix", !".cold"}
Dehao Chen302b69c2016-10-18 20:42:47 +000039!llvm.module.flags = !{!1}
40!1 = !{i32 1, !"ProfileSummary", !2}
41!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
42!3 = !{!"ProfileFormat", !"InstrProf"}
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}
Dehao Chen775341a2017-03-23 23:14:11 +000056!17 = !{!"branch_weights", i32 80}
57!18 = !{!"branch_weights", i32 1}