blob: 4f3144e7fc73b23af61151a3bf99bb494d426adb [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
Teresa Johnson2a6b7992017-05-11 23:18:05 +000013; For instrumentation based PGO, we should only look at entry counts,
14; not call site VP metadata (which can exist on value profiled memcpy,
15; or possibly left behind after static analysis based devirtualization).
16; CHECK: cold_func1{{.*}}!section_prefix ![[COLD_ID:[0-9]+]]
17define void @cold_func1() !prof !16 {
Dehao Chen775341a2017-03-23 23:14:11 +000018 call void @hot_func(), !prof !17
19 call void @hot_func(), !prof !17
20 ret void
21}
22
Teresa Johnson2a6b7992017-05-11 23:18:05 +000023; CHECK: cold_func2{{.*}}!section_prefix
24define void @cold_func2() !prof !16 {
Dehao Chen775341a2017-03-23 23:14:11 +000025 call void @hot_func(), !prof !17
26 call void @hot_func(), !prof !18
27 call void @hot_func(), !prof !18
28 ret void
29}
30
Teresa Johnson2a6b7992017-05-11 23:18:05 +000031; CHECK: cold_func3{{.*}}!section_prefix ![[COLD_ID]]
32define void @cold_func3() !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"}
Teresa Johnson720d9b42017-05-09 01:43:24 +000038; CHECK: ![[COLD_ID]] = !{!"function_section_prefix", !".unlikely"}
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}