xref: /aosp_15_r20/external/llvm/test/tools/llvm-profdata/weight-instr.test (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard WorkerTests for weighted merge of instrumented profiles.
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker1- Merge the foo and bar profiles with unity weight and verify the combined output
4*9880d681SAndroid Build Coastguard WorkerRUN: llvm-profdata merge -instr -weighted-input=1,%p/Inputs/weight-instr-bar.profdata -weighted-input=1,%p/Inputs/weight-instr-foo.profdata -o %t
5*9880d681SAndroid Build Coastguard WorkerRUN: llvm-profdata show -instr -all-functions %t > %t.out1
6*9880d681SAndroid Build Coastguard WorkerRUN: FileCheck %s -check-prefix=1X_1X_WEIGHT --check-prefix=1X_1X_WEIGHT-1 < %t.out1
7*9880d681SAndroid Build Coastguard WorkerRUN: FileCheck %s -check-prefix=1X_1X_WEIGHT --check-prefix=1X_1X_WEIGHT-2 < %t.out1
8*9880d681SAndroid Build Coastguard WorkerRUN: FileCheck %s -check-prefix=1X_1X_WEIGHT --check-prefix=1X_1X_WEIGHT-3 < %t.out1
9*9880d681SAndroid Build Coastguard WorkerRUN: FileCheck %s -check-prefix=1X_1X_WEIGHT --check-prefix=1X_1X_WEIGHT-4 < %t.out1
10*9880d681SAndroid Build Coastguard WorkerRUN: llvm-profdata merge -instr -weighted-input=1,%p/Inputs/weight-instr-bar.profdata %p/Inputs/weight-instr-foo.profdata -o %t
11*9880d681SAndroid Build Coastguard WorkerRUN: llvm-profdata show -instr -all-functions %t > %t.out2
12*9880d681SAndroid Build Coastguard WorkerRUN: FileCheck %s -check-prefix=1X_1X_WEIGHT --check-prefix=1X_1X_WEIGHT-1 < %t.out2
13*9880d681SAndroid Build Coastguard WorkerRUN: FileCheck %s -check-prefix=1X_1X_WEIGHT --check-prefix=1X_1X_WEIGHT-2 < %t.out2
14*9880d681SAndroid Build Coastguard WorkerRUN: FileCheck %s -check-prefix=1X_1X_WEIGHT --check-prefix=1X_1X_WEIGHT-3 < %t.out2
15*9880d681SAndroid Build Coastguard WorkerRUN: FileCheck %s -check-prefix=1X_1X_WEIGHT --check-prefix=1X_1X_WEIGHT-4 < %t.out2
16*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT: Counters:
17*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT-1:   usage:
18*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT-1:     Hash: 0x0000000000000000
19*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT-1:     Counters: 1
20*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT-1:     Function count: 0
21*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT-2:   foo:
22*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT-2:     Hash: 0x000000000000028a
23*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT-2:     Counters: 3
24*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT-2:     Function count: 866988873
25*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT-3:   bar:
26*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT-3:     Hash: 0x000000000000028a
27*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT-3:     Counters: 3
28*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT-3:     Function count: 866988873
29*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT-4:   main:
30*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT-4:     Hash: 0x7d31c47ea98f8248
31*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT-4:     Counters: 60
32*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT-4:     Function count: 2
33*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT:      Functions shown: 4
34*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT-NEXT: Total functions: 4
35*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT-NEXT: Maximum function count: 866988873
36*9880d681SAndroid Build Coastguard Worker1X_1X_WEIGHT-NEXT: Maximum internal block count: 267914296
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Worker2- Merge the foo and bar profiles with weight 3x and 5x respectively and verify the combined output
39*9880d681SAndroid Build Coastguard WorkerRUN: llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=5,%p/Inputs/weight-instr-foo.profdata -o %t
40*9880d681SAndroid Build Coastguard WorkerRUN: llvm-profdata show -instr -all-functions %t > %t.out3
41*9880d681SAndroid Build Coastguard WorkerRUN: FileCheck %s -check-prefix=3X_5X_WEIGHT --check-prefix=3X_5X_WEIGHT-1 < %t.out3
42*9880d681SAndroid Build Coastguard WorkerRUN: FileCheck %s -check-prefix=3X_5X_WEIGHT --check-prefix=3X_5X_WEIGHT-2 < %t.out3
43*9880d681SAndroid Build Coastguard WorkerRUN: FileCheck %s -check-prefix=3X_5X_WEIGHT --check-prefix=3X_5X_WEIGHT-3 < %t.out3
44*9880d681SAndroid Build Coastguard WorkerRUN: FileCheck %s -check-prefix=3X_5X_WEIGHT --check-prefix=3X_5X_WEIGHT-4 < %t.out3
45*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT: Counters:
46*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT-1:   usage:
47*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT-1:     Hash: 0x0000000000000000
48*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT-1:     Counters: 1
49*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT-1:     Function count: 0
50*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT-2:   foo:
51*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT-2:     Hash: 0x000000000000028a
52*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT-2:     Counters: 3
53*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT-2:     Function count: 4334944365
54*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT-3:   bar:
55*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT-3:     Hash: 0x000000000000028a
56*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT-3:     Counters: 3
57*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT-3:     Function count: 2600966619
58*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT-4:   main:
59*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT-4:     Hash: 0x7d31c47ea98f8248
60*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT-4:     Counters: 60
61*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT-4:     Function count: 8
62*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT:      Functions shown: 4
63*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT-NEXT: Total functions: 4
64*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT-NEXT: Maximum function count: 4334944365
65*9880d681SAndroid Build Coastguard Worker3X_5X_WEIGHT-NEXT: Maximum internal block count: 1339571480
66*9880d681SAndroid Build Coastguard Worker
67*9880d681SAndroid Build Coastguard Worker3- Bad merge: invalid weight
68*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=0,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT
69*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=0.75,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT
70*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=-5,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT
71*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT
72*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT
73*9880d681SAndroid Build Coastguard WorkerINVALID_WEIGHT: error: Input weight must be a positive integer.
74*9880d681SAndroid Build Coastguard Worker
75*9880d681SAndroid Build Coastguard Worker4- Bad merge: input path does not exist
76*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/does-not-exist.profdata -weighted-input=2,%p/Inputs/does-not-exist-either.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_INPUT
77*9880d681SAndroid Build Coastguard WorkerINVALID_INPUT: {{.*}}: {{.*}}does-not-exist.profdata: {{[Nn]}}o such file or directory
78*9880d681SAndroid Build Coastguard Worker
79*9880d681SAndroid Build Coastguard Worker5- No inputs
80*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-profdata merge -instr -o %t.out 2>&1 | FileCheck %s -check-prefix=NO_INPUT
81*9880d681SAndroid Build Coastguard WorkerNO_INPUT: {{.*}}: No input files specified. See llvm-profdata{{(\.EXE|\.exe)?}} merge -help
82