Tests for weighted merge of instrumented profiles.
1- Merge the foo and bar profiles with unity weight and verify the combined output
-RUN: llvm-profdata merge --instr %p/Inputs/weight-instr-bar.profdata:1 %p/Inputs/weight-instr-foo.profdata:1 -o %t
-RUN: llvm-profdata show --instr -all-functions %t | FileCheck %s --check-prefix=WEIGHT1
-WEIGHT1: Counters:
-WEIGHT1: usage:
-WEIGHT1: Hash: 0x0000000000000000
-WEIGHT1: Counters: 1
-WEIGHT1: Function count: 0
-WEIGHT1: foo:
-WEIGHT1: Hash: 0x000000000000028a
-WEIGHT1: Counters: 3
-WEIGHT1: Function count: 866988873
-WEIGHT1: bar:
-WEIGHT1: Hash: 0x000000000000028a
-WEIGHT1: Counters: 3
-WEIGHT1: Function count: 866988873
-WEIGHT1: main:
-WEIGHT1: Hash: 0x7d31c47ea98f8248
-WEIGHT1: Counters: 60
-WEIGHT1: Function count: 2
-WEIGHT1: Functions shown: 4
-WEIGHT1: Total functions: 4
-WEIGHT1: Maximum function count: 866988873
-WEIGHT1: Maximum internal block count: 267914296
+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
+RUN: llvm-profdata show -instr -all-functions %t | FileCheck %s -check-prefix=1X_1X_WEIGHT
+RUN: llvm-profdata merge -instr -weighted-input=1,%p/Inputs/weight-instr-bar.profdata %p/Inputs/weight-instr-foo.profdata -o %t
+RUN: llvm-profdata show -instr -all-functions %t | FileCheck %s -check-prefix=1X_1X_WEIGHT
+1X_1X_WEIGHT: Counters:
+1X_1X_WEIGHT-NEXT: usage:
+1X_1X_WEIGHT-NEXT: Hash: 0x0000000000000000
+1X_1X_WEIGHT-NEXT: Counters: 1
+1X_1X_WEIGHT-NEXT: Function count: 0
+1X_1X_WEIGHT-NEXT: foo:
+1X_1X_WEIGHT-NEXT: Hash: 0x000000000000028a
+1X_1X_WEIGHT-NEXT: Counters: 3
+1X_1X_WEIGHT-NEXT: Function count: 866988873
+1X_1X_WEIGHT-NEXT: bar:
+1X_1X_WEIGHT-NEXT: Hash: 0x000000000000028a
+1X_1X_WEIGHT-NEXT: Counters: 3
+1X_1X_WEIGHT-NEXT: Function count: 866988873
+1X_1X_WEIGHT-NEXT: main:
+1X_1X_WEIGHT-NEXT: Hash: 0x7d31c47ea98f8248
+1X_1X_WEIGHT-NEXT: Counters: 60
+1X_1X_WEIGHT-NEXT: Function count: 2
+1X_1X_WEIGHT-NEXT: Functions shown: 4
+1X_1X_WEIGHT-NEXT: Total functions: 4
+1X_1X_WEIGHT-NEXT: Maximum function count: 866988873
+1X_1X_WEIGHT-NEXT: Maximum internal block count: 267914296
2- Merge the foo and bar profiles with weight 3x and 5x respectively and verify the combined output
-RUN: llvm-profdata merge --instr %p/Inputs/weight-instr-bar.profdata:3 %p/Inputs/weight-instr-foo.profdata:5 -o %t
-RUN: llvm-profdata show --instr -all-functions %t | FileCheck %s --check-prefix=WEIGHT2
-WEIGHT2: Counters:
-WEIGHT2: usage:
-WEIGHT2: Hash: 0x0000000000000000
-WEIGHT2: Counters: 1
-WEIGHT2: Function count: 0
-WEIGHT2: foo:
-WEIGHT2: Hash: 0x000000000000028a
-WEIGHT2: Counters: 3
-WEIGHT2: Function count: 4334944365
-WEIGHT2: bar:
-WEIGHT2: Hash: 0x000000000000028a
-WEIGHT2: Counters: 3
-WEIGHT2: Function count: 2600966619
-WEIGHT2: main:
-WEIGHT2: Hash: 0x7d31c47ea98f8248
-WEIGHT2: Counters: 60
-WEIGHT2: Function count: 8
-WEIGHT2: Functions shown: 4
-WEIGHT2: Total functions: 4
-WEIGHT2: Maximum function count: 4334944365
-WEIGHT2: Maximum internal block count: 1339571480
+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
+RUN: llvm-profdata show -instr -all-functions %t | FileCheck %s -check-prefix=3X_5X_WEIGHT
+3X_5X_WEIGHT: Counters:
+3X_5X_WEIGHT-NEXT: usage:
+3X_5X_WEIGHT-NEXT: Hash: 0x0000000000000000
+3X_5X_WEIGHT-NEXT: Counters: 1
+3X_5X_WEIGHT-NEXT: Function count: 0
+3X_5X_WEIGHT-NEXT: foo:
+3X_5X_WEIGHT-NEXT: Hash: 0x000000000000028a
+3X_5X_WEIGHT-NEXT: Counters: 3
+3X_5X_WEIGHT-NEXT: Function count: 4334944365
+3X_5X_WEIGHT-NEXT: bar:
+3X_5X_WEIGHT-NEXT: Hash: 0x000000000000028a
+3X_5X_WEIGHT-NEXT: Counters: 3
+3X_5X_WEIGHT-NEXT: Function count: 2600966619
+3X_5X_WEIGHT-NEXT: main:
+3X_5X_WEIGHT-NEXT: Hash: 0x7d31c47ea98f8248
+3X_5X_WEIGHT-NEXT: Counters: 60
+3X_5X_WEIGHT-NEXT: Function count: 8
+3X_5X_WEIGHT-NEXT: Functions shown: 4
+3X_5X_WEIGHT-NEXT: Total functions: 4
+3X_5X_WEIGHT-NEXT: Maximum function count: 4334944365
+3X_5X_WEIGHT-NEXT: Maximum internal block count: 1339571480
-3- Bad merge: foo and bar profiles with invalid weights
-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
-ERROR3: error: Input weight must be a positive integer.
+3- Bad merge: invalid weight
+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
+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
+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
+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
+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
+INVALID_WEIGHT: error: Input weight must be a positive integer.
+
+4- Bad merge: input path does not exist
+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
+INVALID_INPUT: {{.*}}: {{.*}}does-not-exist.profdata: {{[Nn]}}o such file or directory
+
+5- No inputs
+RUN: not llvm-profdata merge -instr -o %t.out 2>&1 | FileCheck %s -check-prefix=NO_INPUT
+NO_INPUT: {{.*}}: No input files specified. See llvm-profdata{{(\.EXE|\.exe)?}} merge -help