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