1 Some basic tests for supplementing instrumentation profile with sample profile.
3 Test all of goo's counters will be set to PseudoHot.
4 RUN: llvm-profdata merge \
5 RUN: -supplement-instr-with-sample=%p/Inputs/mix_sample.proftext \
6 RUN: -suppl-min-size-threshold=0 %p/Inputs/mix_instr.proftext -o %t
7 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX1
10 MIX1-NEXT: Hash: 0x0000000000000007
11 MIX1-NEXT: Counters: 5
12 MIX1-NEXT: Block counts: [12, 13, 0, 0, 0]
14 MIX1-NEXT: Hash: 0x0000000000000005
15 MIX1-NEXT: Counters: 3
16 MIX1-NOT: Block counts:
17 MIX1-SAME: <PseudoHot>
19 MIX1-NEXT: Hash: 0x0000000000000009
20 MIX1-NEXT: Counters: 4
21 MIX1-NEXT: Block counts: [3000, 1000, 2000, 500]
23 Test when the zero counter ratio of foo is higher than zero-counter-threshold.
24 RUN: llvm-profdata merge \
25 RUN: -supplement-instr-with-sample=%p/Inputs/mix_sample.proftext \
26 RUN: -suppl-min-size-threshold=0 -zero-counter-threshold=0.5 \
27 RUN: -instr-prof-cold-threshold=30 %p/Inputs/mix_instr.proftext -o %t
28 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX2
31 MIX2-NEXT: Hash: 0x0000000000000007
32 MIX2-NEXT: Counters: 5
33 MIX2-NOT: Block counts:
34 MIX2-SAME: <PseudoHot>
36 MIX2-NEXT: Hash: 0x0000000000000005
37 MIX2-NEXT: Counters: 3
38 MIX2-NOT: Block counts:
39 MIX2-SAME: <PseudoHot>
41 MIX2-NEXT: Hash: 0x0000000000000009
42 MIX2-NEXT: Counters: 4
43 MIX2-NEXT: Block counts: [3000, 1000, 2000, 500]
45 Test when the zero counter ratio of foo is lower than zero-counter-threshold.
46 RUN: llvm-profdata merge \
47 RUN: -supplement-instr-with-sample=%p/Inputs/mix_sample.proftext \
48 RUN: -suppl-min-size-threshold=0 -zero-counter-threshold=0.7 \
49 RUN: -instr-prof-cold-threshold=30 %p/Inputs/mix_instr.proftext -o %t
50 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX3
53 MIX3-NEXT: Hash: 0x0000000000000007
54 MIX3-NEXT: Counters: 5
55 MIX3-NEXT: Block counts: [1384, 1500, 0, 0, 0]
57 MIX3-NEXT: Hash: 0x0000000000000005
58 MIX3-NEXT: Counters: 3
59 MIX3-NOT: Block counts:
60 MIX3-SAME: <PseudoHot>
62 MIX3-NEXT: Hash: 0x0000000000000009
63 MIX3-NEXT: Counters: 4
64 MIX3-NEXT: Block counts: [3000, 1000, 2000, 500]
66 Test foo's profile won't be adjusted because its size is smaller
67 than suppl-min-size-threshold.
68 RUN: llvm-profdata merge \
69 RUN: -supplement-instr-with-sample=%p/Inputs/mix_sample.proftext \
70 RUN: -suppl-min-size-threshold=2 -zero-counter-threshold=0.7 \
71 RUN: -instr-prof-cold-threshold=30 %p/Inputs/mix_instr_small.proftext -o %t
72 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX4
75 MIX4-NEXT: Hash: 0x0000000000000007
76 MIX4-NEXT: Counters: 1
77 MIX4-NEXT: Block counts: [0]
79 MIX4-NEXT: Hash: 0x0000000000000005
80 MIX4-NEXT: Counters: 3
81 MIX4-NOT: Block counts:
82 MIX4-SAME: <PseudoHot>
84 MIX4-NEXT: Hash: 0x0000000000000009
85 MIX4-NEXT: Counters: 1
86 MIX4-NEXT: Block counts: [0]
88 Test profile summary won't be affected by pseudo counters.
89 RUN: llvm-profdata merge \
90 RUN: -supplement-instr-with-sample=%p/Inputs/mix_sample.proftext \
91 RUN: -suppl-min-size-threshold=0 %p/Inputs/mix_instr.proftext -o %t
92 RUN: llvm-profdata show %t -detailed-summary | FileCheck %s --check-prefix=MIX5
94 MIX5: Instrumentation level: IR
95 MIX5-NEXT: Total functions: 2
96 MIX5-NEXT: Maximum function count: 3000
97 MIX5-NEXT: Maximum internal block count: 2000
98 MIX5-NEXT: Total number of blocks: 9
99 MIX5-NEXT: Total count: 6525
100 MIX5-NEXT: Detailed summary:
101 MIX5-NEXT: 1 blocks with count >= 3000 account for 1 percentage of the total counts.
102 MIX5-NEXT: 1 blocks with count >= 3000 account for 10 percentage of the total counts.
103 MIX5-NEXT: 1 blocks with count >= 3000 account for 20 percentage of the total counts.
104 MIX5-NEXT: 1 blocks with count >= 3000 account for 30 percentage of the total counts.
105 MIX5-NEXT: 1 blocks with count >= 3000 account for 40 percentage of the total counts.
106 MIX5-NEXT: 2 blocks with count >= 2000 account for 50 percentage of the total counts.
107 MIX5-NEXT: 2 blocks with count >= 2000 account for 60 percentage of the total counts.
108 MIX5-NEXT: 2 blocks with count >= 2000 account for 70 percentage of the total counts.
109 MIX5-NEXT: 3 blocks with count >= 1000 account for 80 percentage of the total counts.
110 MIX5-NEXT: 3 blocks with count >= 1000 account for 90 percentage of the total counts.
111 MIX5-NEXT: 4 blocks with count >= 500 account for 95 percentage of the total counts.
112 MIX5-NEXT: 4 blocks with count >= 500 account for 99 percentage of the total counts.
113 MIX5-NEXT: 6 blocks with count >= 12 account for 99.9 percentage of the total counts.
114 MIX5-NEXT: 6 blocks with count >= 12 account for 99.99 percentage of the total counts.
115 MIX5-NEXT: 6 blocks with count >= 12 account for 99.999 percentage of the total counts.
116 MIX5-NEXT: 6 blocks with count >= 12 account for 99.9999 percentage of the total counts.