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