1 ; RUN: opt < %s -passes=pgo-force-function-attrs -pgo-kind=pgo-instr-use-pipeline -S -pgo-cold-func-opt=default | FileCheck %s --check-prefixes=NONE,CHECK
2 ; RUN: opt < %s -passes=pgo-force-function-attrs -pgo-kind=pgo-instr-use-pipeline -S -pgo-cold-func-opt=optsize | FileCheck %s --check-prefixes=OPTSIZE,CHECK
3 ; RUN: opt < %s -passes=pgo-force-function-attrs -pgo-kind=pgo-instr-use-pipeline -S -pgo-cold-func-opt=minsize | FileCheck %s --check-prefixes=MINSIZE,CHECK
4 ; RUN: opt < %s -passes=pgo-force-function-attrs -pgo-kind=pgo-instr-use-pipeline -S -pgo-cold-func-opt=optnone | FileCheck %s --check-prefixes=OPTNONE,CHECK
6 ; Should be no changes without profile data
7 ; RUN: opt < %s -passes=pgo-force-function-attrs -S -pgo-cold-func-opt=minsize | FileCheck %s --check-prefixes=NONE,CHECK
9 ; NONE-NOT: Function Attrs:
10 ; OPTSIZE: Function Attrs: optsize{{$}}
11 ; MINSIZE: Function Attrs: minsize{{$}}
12 ; OPTNONE: Function Attrs: noinline optnone{{$}}
13 ; CHECK: define void @cold()
15 ; CHECK: Function Attrs: optsize{{$}}
16 ; CHECK-NEXT: define void @cold_optsize()
18 ; CHECK: Function Attrs: minsize{{$}}
19 ; CHECK-NEXT: define void @cold_minsize()
21 ; CHECK: Function Attrs: noinline optnone{{$}}
22 ; CHECK-NEXT: define void @cold_optnone()
24 ; NONE: Function Attrs: alwaysinline{{$}}
25 ; OPTSIZE: Function Attrs: alwaysinline optsize{{$}}
26 ; MINSIZE: Function Attrs: alwaysinline minsize{{$}}
27 ; OPTNONE: Function Attrs: alwaysinline{{$}}
28 ; CHECK-NEXT: define void @cold_alwaysinline()
30 ; NONE: Function Attrs: cold{{$}}
31 ; OPTSIZE: Function Attrs: cold optsize{{$}}
32 ; MINSIZE: Function Attrs: cold minsize{{$}}
33 ; OPTNONE: Function Attrs: cold noinline optnone{{$}}
34 ; CHECK-NEXT: define void @cold_attr()
36 ; CHECK-NOT: Function Attrs: {{.*}}optsize
37 ; CHECK-NOT: Function Attrs: {{.*}}minsize
38 ; CHECK-NOT: Function Attrs: {{.*}}optnone
40 ; O2: define void @cold_attr(){{.*}} #[[ATTR:[0-9]+]]
41 ; O2-NOT: #[[ATTR]] = {{.*}}minsize
45 define void @cold() !prof !27 {
46 store i32 1, ptr @s, align 4
50 define void @cold_optsize() optsize !prof !27 {
51 store i32 1, ptr @s, align 4
55 define void @cold_minsize() minsize !prof !27 {
56 store i32 1, ptr @s, align 4
60 define void @cold_optnone() noinline optnone !prof !27 {
61 store i32 1, ptr @s, align 4
65 define void @cold_alwaysinline() alwaysinline !prof !27 {
66 store i32 1, ptr @s, align 4
70 define void @cold_attr() cold {
71 store i32 1, ptr @s, align 4
75 define void @hot() !prof !28 {
76 %l = load i32, ptr @s, align 4
77 %add = add nsw i32 %l, 4
78 store i32 %add, ptr @s, align 4
82 attributes #0 = { optsize }
83 attributes #1 = { minsize }
84 attributes #2 = { noinline optnone }
86 !llvm.module.flags = !{!0}
88 !0 = !{i32 1, !"ProfileSummary", !1}
89 !1 = !{!2, !3, !4, !5, !6, !7, !8, !9}
90 !2 = !{!"ProfileFormat", !"InstrProf"}
91 !3 = !{!"TotalCount", i64 9040}
92 !4 = !{!"MaxCount", i64 9000}
93 !5 = !{!"MaxInternalCount", i64 0}
94 !6 = !{!"MaxFunctionCount", i64 9000}
95 !7 = !{!"NumCounts", i64 5}
96 !8 = !{!"NumFunctions", i64 5}
97 !9 = !{!"DetailedSummary", !10}
98 !10 = !{!11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26}
99 !11 = !{i32 10000, i64 9000, i32 1}
100 !12 = !{i32 100000, i64 9000, i32 1}
101 !13 = !{i32 200000, i64 9000, i32 1}
102 !14 = !{i32 300000, i64 9000, i32 1}
103 !15 = !{i32 400000, i64 9000, i32 1}
104 !16 = !{i32 500000, i64 9000, i32 1}
105 !17 = !{i32 600000, i64 9000, i32 1}
106 !18 = !{i32 700000, i64 9000, i32 1}
107 !19 = !{i32 800000, i64 9000, i32 1}
108 !20 = !{i32 900000, i64 9000, i32 1}
109 !21 = !{i32 950000, i64 9000, i32 1}
110 !22 = !{i32 990000, i64 9000, i32 1}
111 !23 = !{i32 999000, i64 10, i32 5}
112 !24 = !{i32 999900, i64 10, i32 5}
113 !25 = !{i32 999990, i64 10, i32 5}
114 !26 = !{i32 999999, i64 10, i32 5}
115 !27 = !{!"function_entry_count", i64 10}
116 !28 = !{!"function_entry_count", i64 9000}