• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Tests 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 > %t.out1
6RUN: FileCheck %s -check-prefix=1X_1X_WEIGHT --check-prefix=1X_1X_WEIGHT-1 < %t.out1
7RUN: FileCheck %s -check-prefix=1X_1X_WEIGHT --check-prefix=1X_1X_WEIGHT-2 < %t.out1
8RUN: FileCheck %s -check-prefix=1X_1X_WEIGHT --check-prefix=1X_1X_WEIGHT-3 < %t.out1
9RUN: FileCheck %s -check-prefix=1X_1X_WEIGHT --check-prefix=1X_1X_WEIGHT-4 < %t.out1
10RUN: llvm-profdata merge -instr -weighted-input=1,%p/Inputs/weight-instr-bar.profdata %p/Inputs/weight-instr-foo.profdata -o %t
11RUN: llvm-profdata show -instr -all-functions %t > %t.out2
12RUN: FileCheck %s -check-prefix=1X_1X_WEIGHT --check-prefix=1X_1X_WEIGHT-1 < %t.out2
13RUN: FileCheck %s -check-prefix=1X_1X_WEIGHT --check-prefix=1X_1X_WEIGHT-2 < %t.out2
14RUN: FileCheck %s -check-prefix=1X_1X_WEIGHT --check-prefix=1X_1X_WEIGHT-3 < %t.out2
15RUN: FileCheck %s -check-prefix=1X_1X_WEIGHT --check-prefix=1X_1X_WEIGHT-4 < %t.out2
161X_1X_WEIGHT: Counters:
171X_1X_WEIGHT-1:   usage:
181X_1X_WEIGHT-1:     Hash: 0x0000000000000000
191X_1X_WEIGHT-1:     Counters: 1
201X_1X_WEIGHT-1:     Function count: 0
211X_1X_WEIGHT-2:   foo:
221X_1X_WEIGHT-2:     Hash: 0x000000000000028a
231X_1X_WEIGHT-2:     Counters: 3
241X_1X_WEIGHT-2:     Function count: 866988873
251X_1X_WEIGHT-3:   bar:
261X_1X_WEIGHT-3:     Hash: 0x000000000000028a
271X_1X_WEIGHT-3:     Counters: 3
281X_1X_WEIGHT-3:     Function count: 866988873
291X_1X_WEIGHT-4:   main:
301X_1X_WEIGHT-4:     Hash: 0x7d31c47ea98f8248
311X_1X_WEIGHT-4:     Counters: 60
321X_1X_WEIGHT-4:     Function count: 2
331X_1X_WEIGHT:      Functions shown: 4
341X_1X_WEIGHT-NEXT: Total functions: 4
351X_1X_WEIGHT-NEXT: Maximum function count: 866988873
361X_1X_WEIGHT-NEXT: Maximum internal block count: 267914296
37
382- Merge the foo and bar profiles with weight 3x and 5x respectively and verify the combined output
39RUN: llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=5,%p/Inputs/weight-instr-foo.profdata -o %t
40RUN: llvm-profdata show -instr -all-functions %t > %t.out3
41RUN: FileCheck %s -check-prefix=3X_5X_WEIGHT --check-prefix=3X_5X_WEIGHT-1 < %t.out3
42RUN: FileCheck %s -check-prefix=3X_5X_WEIGHT --check-prefix=3X_5X_WEIGHT-2 < %t.out3
43RUN: FileCheck %s -check-prefix=3X_5X_WEIGHT --check-prefix=3X_5X_WEIGHT-3 < %t.out3
44RUN: FileCheck %s -check-prefix=3X_5X_WEIGHT --check-prefix=3X_5X_WEIGHT-4 < %t.out3
453X_5X_WEIGHT: Counters:
463X_5X_WEIGHT-1:   usage:
473X_5X_WEIGHT-1:     Hash: 0x0000000000000000
483X_5X_WEIGHT-1:     Counters: 1
493X_5X_WEIGHT-1:     Function count: 0
503X_5X_WEIGHT-2:   foo:
513X_5X_WEIGHT-2:     Hash: 0x000000000000028a
523X_5X_WEIGHT-2:     Counters: 3
533X_5X_WEIGHT-2:     Function count: 4334944365
543X_5X_WEIGHT-3:   bar:
553X_5X_WEIGHT-3:     Hash: 0x000000000000028a
563X_5X_WEIGHT-3:     Counters: 3
573X_5X_WEIGHT-3:     Function count: 2600966619
583X_5X_WEIGHT-4:   main:
593X_5X_WEIGHT-4:     Hash: 0x7d31c47ea98f8248
603X_5X_WEIGHT-4:     Counters: 60
613X_5X_WEIGHT-4:     Function count: 8
623X_5X_WEIGHT:      Functions shown: 4
633X_5X_WEIGHT-NEXT: Total functions: 4
643X_5X_WEIGHT-NEXT: Maximum function count: 4334944365
653X_5X_WEIGHT-NEXT: Maximum internal block count: 1339571480
66
673- Bad merge: invalid weight
68RUN: 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
69RUN: 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
70RUN: 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
71RUN: 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
72RUN: 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
73INVALID_WEIGHT: error: Input weight must be a positive integer.
74
754- Bad merge: input path does not exist
76RUN: 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
77INVALID_INPUT: {{.*}}: {{.*}}does-not-exist.profdata: {{[Nn]}}o such file or directory
78
795- No inputs
80RUN: not llvm-profdata merge -instr -o %t.out 2>&1 | FileCheck %s -check-prefix=NO_INPUT
81NO_INPUT: {{.*}}: No input files specified. See llvm-profdata{{(\.EXE|\.exe)?}} merge -help
82