1 ; RUN: opt < %s -codegenprepare -S | FileCheck %s
3 target triple = "x86_64-pc-linux-gnu"
5 ; This tests that hot/cold functions get correct section prefix assigned
7 ; CHECK: hot_func1{{.*}}!section_prefix ![[HOT_ID:[0-9]+]]
9 define void @hot_func1() !prof !15 {
13 ; CHECK: hot_func2{{.*}}!section_prefix ![[HOT_ID:[0-9]+]]
14 ; Entry is cold but inner block is hot
15 define void @hot_func2(i32 %n) !prof !16 {
17 %n.addr = alloca i32, align 4
18 %i = alloca i32, align 4
19 store i32 %n, i32* %n.addr, align 4
20 store i32 0, i32* %i, align 4
24 %0 = load i32, i32* %i, align 4
25 %1 = load i32, i32* %n.addr, align 4
26 %cmp = icmp slt i32 %0, %1
27 br i1 %cmp, label %for.body, label %for.end, !prof !19
30 %2 = load i32, i32* %i, align 4
31 %inc = add nsw i32 %2, 1
32 store i32 %inc, i32* %i, align 4
39 ; For instrumentation based PGO, we should only look at block counts,
40 ; not call site VP metadata (which can exist on value profiled memcpy,
41 ; or possibly left behind after static analysis based devirtualization).
42 ; CHECK: cold_func1{{.*}}!section_prefix ![[COLD_ID:[0-9]+]]
43 define void @cold_func1() !prof !16 {
44 call void @hot_func1(), !prof !17
45 call void @hot_func1(), !prof !17
49 ; CHECK: cold_func2{{.*}}!section_prefix ![[COLD_ID]]
50 define void @cold_func2() !prof !16 {
51 call void @hot_func1(), !prof !17
52 call void @hot_func1(), !prof !18
53 call void @hot_func1(), !prof !18
57 ; CHECK: cold_func3{{.*}}!section_prefix ![[COLD_ID]]
58 define void @cold_func3() !prof !16 {
59 call void @hot_func1(), !prof !18
63 ; CHECK: ![[HOT_ID]] = !{!"function_section_prefix", !".hot"}
64 ; CHECK: ![[COLD_ID]] = !{!"function_section_prefix", !".unlikely"}
65 !llvm.module.flags = !{!1}
66 !1 = !{i32 1, !"ProfileSummary", !2}
67 !2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
68 !3 = !{!"ProfileFormat", !"InstrProf"}
69 !4 = !{!"TotalCount", i64 10000}
70 !5 = !{!"MaxCount", i64 1000}
71 !6 = !{!"MaxInternalCount", i64 1}
72 !7 = !{!"MaxFunctionCount", i64 1000}
73 !8 = !{!"NumCounts", i64 3}
74 !9 = !{!"NumFunctions", i64 3}
75 !10 = !{!"DetailedSummary", !11}
76 !11 = !{!12, !13, !14}
77 !12 = !{i32 10000, i64 100, i32 1}
78 !13 = !{i32 999000, i64 100, i32 1}
79 !14 = !{i32 999999, i64 1, i32 2}
80 !15 = !{!"function_entry_count", i64 1000}
81 !16 = !{!"function_entry_count", i64 1}
82 !17 = !{!"branch_weights", i32 80}
83 !18 = !{!"branch_weights", i32 1}
84 !19 = !{!"branch_weights", i32 1000, i32 1}