[llvm-profdata] Add support for weighted merge of profile data
[oota-llvm.git] / test / tools / llvm-profdata / weight-instr.test
1 Tests for weighted merge of instrumented profiles.
2
3 1- Merge the foo and bar profiles with unity weight and verify the combined output
4 RUN: llvm-profdata merge --instr %p/Inputs/weight-instr-bar.profdata:1 %p/Inputs/weight-instr-foo.profdata:1 -o %t
5 RUN: llvm-profdata show --instr -all-functions %t | FileCheck %s --check-prefix=WEIGHT1
6 WEIGHT1: Counters:
7 WEIGHT1:   usage:
8 WEIGHT1:     Hash: 0x0000000000000000
9 WEIGHT1:     Counters: 1
10 WEIGHT1:     Function count: 0
11 WEIGHT1:   foo:
12 WEIGHT1:     Hash: 0x000000000000028a
13 WEIGHT1:     Counters: 3
14 WEIGHT1:     Function count: 866988873
15 WEIGHT1:   bar:
16 WEIGHT1:     Hash: 0x000000000000028a
17 WEIGHT1:     Counters: 3
18 WEIGHT1:     Function count: 866988873
19 WEIGHT1:   main:
20 WEIGHT1:     Hash: 0x7d31c47ea98f8248
21 WEIGHT1:     Counters: 60
22 WEIGHT1:     Function count: 2
23 WEIGHT1: Functions shown: 4
24 WEIGHT1: Total functions: 4
25 WEIGHT1: Maximum function count: 866988873
26 WEIGHT1: Maximum internal block count: 267914296
27
28 2- Merge the foo and bar profiles with weight 3x and 5x respectively and verify the combined output
29 RUN: llvm-profdata merge --instr %p/Inputs/weight-instr-bar.profdata:3 %p/Inputs/weight-instr-foo.profdata:5 -o %t
30 RUN: llvm-profdata show --instr -all-functions %t | FileCheck %s --check-prefix=WEIGHT2
31 WEIGHT2: Counters:
32 WEIGHT2:   usage:
33 WEIGHT2:     Hash: 0x0000000000000000
34 WEIGHT2:     Counters: 1
35 WEIGHT2:     Function count: 0
36 WEIGHT2:   foo:
37 WEIGHT2:     Hash: 0x000000000000028a
38 WEIGHT2:     Counters: 3
39 WEIGHT2:     Function count: 4334944365
40 WEIGHT2:   bar:
41 WEIGHT2:     Hash: 0x000000000000028a
42 WEIGHT2:     Counters: 3
43 WEIGHT2:     Function count: 2600966619
44 WEIGHT2:   main:
45 WEIGHT2:     Hash: 0x7d31c47ea98f8248
46 WEIGHT2:     Counters: 60
47 WEIGHT2:     Function count: 8
48 WEIGHT2: Functions shown: 4
49 WEIGHT2: Total functions: 4
50 WEIGHT2: Maximum function count: 4334944365
51 WEIGHT2: Maximum internal block count: 1339571480
52
53 3- Bad merge: foo and bar profiles with invalid weights
54 RUN: not llvm-profdata merge --instr %p/Inputs/weight-instr-bar.profdata:3 %p/Inputs/weight-instr-foo.profdata:-5 -o %t.out 2>&1 | FileCheck %s --check-prefix=ERROR3
55 ERROR3: error: Input weight must be a positive integer.