|
| 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 |
| 5 | + |
| 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 |
| 8 | + |
| 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() |
| 14 | + |
| 15 | +; CHECK: Function Attrs: optsize{{$}} |
| 16 | +; CHECK-NEXT: define void @cold_optsize() |
| 17 | + |
| 18 | +; CHECK: Function Attrs: minsize{{$}} |
| 19 | +; CHECK-NEXT: define void @cold_minsize() |
| 20 | + |
| 21 | +; CHECK: Function Attrs: noinline optnone{{$}} |
| 22 | +; CHECK-NEXT: define void @cold_optnone() |
| 23 | + |
| 24 | +; NONE: Function Attrs: cold{{$}} |
| 25 | +; OPTSIZE: Function Attrs: cold optsize{{$}} |
| 26 | +; MINSIZE: Function Attrs: cold minsize{{$}} |
| 27 | +; OPTNONE: Function Attrs: cold noinline optnone{{$}} |
| 28 | +; CHECK-NEXT: define void @cold_attr() |
| 29 | + |
| 30 | +; CHECK-NOT: Function Attrs: {{.*}}optsize |
| 31 | +; CHECK-NOT: Function Attrs: {{.*}}minsize |
| 32 | +; CHECK-NOT: Function Attrs: {{.*}}optnone |
| 33 | + |
| 34 | +@s = global i32 0 |
| 35 | + |
| 36 | +define void @cold() !prof !27 { |
| 37 | + store i32 1, ptr @s, align 4 |
| 38 | + ret void |
| 39 | +} |
| 40 | + |
| 41 | +define void @cold_optsize() optsize !prof !27 { |
| 42 | + store i32 1, ptr @s, align 4 |
| 43 | + ret void |
| 44 | +} |
| 45 | + |
| 46 | +define void @cold_minsize() minsize !prof !27 { |
| 47 | + store i32 1, ptr @s, align 4 |
| 48 | + ret void |
| 49 | +} |
| 50 | + |
| 51 | +define void @cold_optnone() noinline optnone !prof !27 { |
| 52 | + store i32 1, ptr @s, align 4 |
| 53 | + ret void |
| 54 | +} |
| 55 | + |
| 56 | +define void @cold_attr() cold { |
| 57 | + store i32 1, ptr @s, align 4 |
| 58 | + ret void |
| 59 | +} |
| 60 | + |
| 61 | +define void @hot() !prof !28 { |
| 62 | + %l = load i32, ptr @s, align 4 |
| 63 | + %add = add nsw i32 %l, 4 |
| 64 | + store i32 %add, ptr @s, align 4 |
| 65 | + ret void |
| 66 | +} |
| 67 | + |
| 68 | +attributes #0 = { optsize } |
| 69 | +attributes #1 = { minsize } |
| 70 | +attributes #2 = { noinline optnone } |
| 71 | + |
| 72 | +!llvm.module.flags = !{!0} |
| 73 | + |
| 74 | +!0 = !{i32 1, !"ProfileSummary", !1} |
| 75 | +!1 = !{!2, !3, !4, !5, !6, !7, !8, !9} |
| 76 | +!2 = !{!"ProfileFormat", !"InstrProf"} |
| 77 | +!3 = !{!"TotalCount", i64 9040} |
| 78 | +!4 = !{!"MaxCount", i64 9000} |
| 79 | +!5 = !{!"MaxInternalCount", i64 0} |
| 80 | +!6 = !{!"MaxFunctionCount", i64 9000} |
| 81 | +!7 = !{!"NumCounts", i64 5} |
| 82 | +!8 = !{!"NumFunctions", i64 5} |
| 83 | +!9 = !{!"DetailedSummary", !10} |
| 84 | +!10 = !{!11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26} |
| 85 | +!11 = !{i32 10000, i64 9000, i32 1} |
| 86 | +!12 = !{i32 100000, i64 9000, i32 1} |
| 87 | +!13 = !{i32 200000, i64 9000, i32 1} |
| 88 | +!14 = !{i32 300000, i64 9000, i32 1} |
| 89 | +!15 = !{i32 400000, i64 9000, i32 1} |
| 90 | +!16 = !{i32 500000, i64 9000, i32 1} |
| 91 | +!17 = !{i32 600000, i64 9000, i32 1} |
| 92 | +!18 = !{i32 700000, i64 9000, i32 1} |
| 93 | +!19 = !{i32 800000, i64 9000, i32 1} |
| 94 | +!20 = !{i32 900000, i64 9000, i32 1} |
| 95 | +!21 = !{i32 950000, i64 9000, i32 1} |
| 96 | +!22 = !{i32 990000, i64 9000, i32 1} |
| 97 | +!23 = !{i32 999000, i64 10, i32 5} |
| 98 | +!24 = !{i32 999900, i64 10, i32 5} |
| 99 | +!25 = !{i32 999990, i64 10, i32 5} |
| 100 | +!26 = !{i32 999999, i64 10, i32 5} |
| 101 | +!27 = !{!"function_entry_count", i64 10} |
| 102 | +!28 = !{!"function_entry_count", i64 9000} |
0 commit comments