Dehao Chen | 4b41571 | 2016-10-19 03:53:41 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -codegenprepare -S | FileCheck %s |
Dehao Chen | 302b69c | 2016-10-18 20:42:47 +0000 | [diff] [blame] | 2 | |
Dehao Chen | 83033e0 | 2016-10-18 21:13:31 +0000 | [diff] [blame] | 3 | target triple = "x86_64-pc-linux-gnu" |
| 4 | |
Dehao Chen | 302b69c | 2016-10-18 20:42:47 +0000 | [diff] [blame] | 5 | ; This tests that hot/cold functions get correct section prefix assigned |
| 6 | |
Dehao Chen | 4b41571 | 2016-10-19 03:53:41 +0000 | [diff] [blame] | 7 | ; CHECK: hot_func{{.*}}!section_prefix ![[HOT_ID:[0-9]+]] |
Dehao Chen | 775341a | 2017-03-23 23:14:11 +0000 | [diff] [blame] | 8 | ; The entry is hot |
Dehao Chen | 302b69c | 2016-10-18 20:42:47 +0000 | [diff] [blame] | 9 | define void @hot_func() !prof !15 { |
| 10 | ret void |
| 11 | } |
| 12 | |
Teresa Johnson | 2a6b799 | 2017-05-11 23:18:05 +0000 | [diff] [blame] | 13 | ; 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]+]] |
| 17 | define void @cold_func1() !prof !16 { |
Dehao Chen | 775341a | 2017-03-23 23:14:11 +0000 | [diff] [blame] | 18 | call void @hot_func(), !prof !17 |
| 19 | call void @hot_func(), !prof !17 |
| 20 | ret void |
| 21 | } |
| 22 | |
Teresa Johnson | 2a6b799 | 2017-05-11 23:18:05 +0000 | [diff] [blame] | 23 | ; CHECK: cold_func2{{.*}}!section_prefix |
| 24 | define void @cold_func2() !prof !16 { |
Dehao Chen | 775341a | 2017-03-23 23:14:11 +0000 | [diff] [blame] | 25 | 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 Johnson | 2a6b799 | 2017-05-11 23:18:05 +0000 | [diff] [blame] | 31 | ; CHECK: cold_func3{{.*}}!section_prefix ![[COLD_ID]] |
| 32 | define void @cold_func3() !prof !16 { |
Dehao Chen | 775341a | 2017-03-23 23:14:11 +0000 | [diff] [blame] | 33 | call void @hot_func(), !prof !18 |
Dehao Chen | 302b69c | 2016-10-18 20:42:47 +0000 | [diff] [blame] | 34 | ret void |
| 35 | } |
| 36 | |
Dehao Chen | 4b41571 | 2016-10-19 03:53:41 +0000 | [diff] [blame] | 37 | ; CHECK: ![[HOT_ID]] = !{!"function_section_prefix", !".hot"} |
Teresa Johnson | 720d9b4 | 2017-05-09 01:43:24 +0000 | [diff] [blame] | 38 | ; CHECK: ![[COLD_ID]] = !{!"function_section_prefix", !".unlikely"} |
Dehao Chen | 302b69c | 2016-10-18 20:42:47 +0000 | [diff] [blame] | 39 | !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 Chen | 775341a | 2017-03-23 23:14:11 +0000 | [diff] [blame] | 56 | !17 = !{!"branch_weights", i32 80} |
| 57 | !18 = !{!"branch_weights", i32 1} |