blob: 7294cf3b01f04d4c4bf20eb0cc1c2e4ee4871fc5 [file] [log] [blame]
Nathan Slingerland7f5b47d2015-12-15 17:37:09 +00001Tests for weighted merge of instrumented profiles.
2
31- Merge the foo and bar profiles with unity weight and verify the combined output
4RUN: llvm-profdata merge -instr -weighted-input=1,%p/Inputs/weight-instr-bar.profdata -weighted-input=1,%p/Inputs/weight-instr-foo.profdata -o %t
5RUN: llvm-profdata show -instr -all-functions %t | FileCheck %s -check-prefix=1X_1X_WEIGHT
6RUN: llvm-profdata merge -instr -weighted-input=1,%p/Inputs/weight-instr-bar.profdata %p/Inputs/weight-instr-foo.profdata -o %t
7RUN: llvm-profdata show -instr -all-functions %t | FileCheck %s -check-prefix=1X_1X_WEIGHT
81X_1X_WEIGHT: Counters:
91X_1X_WEIGHT-NEXT: usage:
101X_1X_WEIGHT-NEXT: Hash: 0x0000000000000000
111X_1X_WEIGHT-NEXT: Counters: 1
121X_1X_WEIGHT-NEXT: Function count: 0
131X_1X_WEIGHT-NEXT: foo:
141X_1X_WEIGHT-NEXT: Hash: 0x000000000000028a
151X_1X_WEIGHT-NEXT: Counters: 3
161X_1X_WEIGHT-NEXT: Function count: 866988873
171X_1X_WEIGHT-NEXT: bar:
181X_1X_WEIGHT-NEXT: Hash: 0x000000000000028a
191X_1X_WEIGHT-NEXT: Counters: 3
201X_1X_WEIGHT-NEXT: Function count: 866988873
211X_1X_WEIGHT-NEXT: main:
221X_1X_WEIGHT-NEXT: Hash: 0x7d31c47ea98f8248
231X_1X_WEIGHT-NEXT: Counters: 60
241X_1X_WEIGHT-NEXT: Function count: 2
251X_1X_WEIGHT-NEXT: Functions shown: 4
261X_1X_WEIGHT-NEXT: Total functions: 4
271X_1X_WEIGHT-NEXT: Maximum function count: 866988873
281X_1X_WEIGHT-NEXT: Maximum internal block count: 267914296
29
302- Merge the foo and bar profiles with weight 3x and 5x respectively and verify the combined output
31RUN: llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=5,%p/Inputs/weight-instr-foo.profdata -o %t
32RUN: llvm-profdata show -instr -all-functions %t | FileCheck %s -check-prefix=3X_5X_WEIGHT
333X_5X_WEIGHT: Counters:
343X_5X_WEIGHT-NEXT: usage:
353X_5X_WEIGHT-NEXT: Hash: 0x0000000000000000
363X_5X_WEIGHT-NEXT: Counters: 1
373X_5X_WEIGHT-NEXT: Function count: 0
383X_5X_WEIGHT-NEXT: foo:
393X_5X_WEIGHT-NEXT: Hash: 0x000000000000028a
403X_5X_WEIGHT-NEXT: Counters: 3
413X_5X_WEIGHT-NEXT: Function count: 4334944365
423X_5X_WEIGHT-NEXT: bar:
433X_5X_WEIGHT-NEXT: Hash: 0x000000000000028a
443X_5X_WEIGHT-NEXT: Counters: 3
453X_5X_WEIGHT-NEXT: Function count: 2600966619
463X_5X_WEIGHT-NEXT: main:
473X_5X_WEIGHT-NEXT: Hash: 0x7d31c47ea98f8248
483X_5X_WEIGHT-NEXT: Counters: 60
493X_5X_WEIGHT-NEXT: Function count: 8
503X_5X_WEIGHT-NEXT: Functions shown: 4
513X_5X_WEIGHT-NEXT: Total functions: 4
523X_5X_WEIGHT-NEXT: Maximum function count: 4334944365
533X_5X_WEIGHT-NEXT: Maximum internal block count: 1339571480
54
553- Bad merge: invalid weight
56RUN: 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
57RUN: 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
58RUN: 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
59RUN: 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
60RUN: 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
61INVALID_WEIGHT: error: Input weight must be a positive integer.
62
634- Bad merge: input path does not exist
64RUN: 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
65INVALID_INPUT: {{.*}}: {{.*}}does-not-exist.profdata: {{[Nn]}}o such file or directory
66
675- No inputs
68RUN: not llvm-profdata merge -instr -o %t.out 2>&1 | FileCheck %s -check-prefix=NO_INPUT
69NO_INPUT: {{.*}}: No input files specified. See llvm-profdata{{(\.EXE|\.exe)?}} merge -help