1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00
llvm-mirror/test/tools/llvm-profdata/weight-sample.test
Vedant Kumar 45e8fa3b9a [sampleprof] Drop test dependency on the string hash func (NFC)
The SampleProfWriter emits function information in an order determined
by the string hash function. The situation is a bit brittle, because
changing the hash function can break the tests.

Instead of sorting the function samples to get a relaible ordering (that
might be too expensive), make the tests not depend on a particular
ordering of function samples.

Differential Revision: https://reviews.llvm.org/D32516

llvm-svn: 301419
2017-04-26 15:39:53 +00:00

57 lines
3.4 KiB
Plaintext

Tests for weighted merge of sample profiles.
1- Merge the foo and bar profiles with unity weight and verify the combined output
RUN: llvm-profdata merge -sample -text -weighted-input=1,%p/Inputs/weight-sample-bar.proftext -weighted-input=1,%p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s -check-prefix=1X_1X_WEIGHT
RUN: llvm-profdata merge -sample -text -weighted-input=1,%p/Inputs/weight-sample-bar.proftext %p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s -check-prefix=1X_1X_WEIGHT
1X_1X_WEIGHT-DAG: foo:1763288:35327
1X_1X_WEIGHT-DAG: 7: 35327
1X_1X_WEIGHT-DAG: 8: 35327
1X_1X_WEIGHT-DAG: 9: 6930
1X_1X_WEIGHT-DAG: 10: 29341
1X_1X_WEIGHT-DAG: 11: 11906
1X_1X_WEIGHT-DAG: 13: 18185 foo:19531
1X_1X_WEIGHT-DAG: 15: 36458
1X_1X_WEIGHT-DAG: bar:1772037:35370
1X_1X_WEIGHT-DAG: 17: 35370
1X_1X_WEIGHT-DAG: 18: 35370
1X_1X_WEIGHT-DAG: 19: 7005
1X_1X_WEIGHT-DAG: 20: 29407
1X_1X_WEIGHT-DAG: 21: 12170
1X_1X_WEIGHT-DAG: 23: 18150 bar:19829
1X_1X_WEIGHT-DAG: 25: 36666
2- Merge the foo and bar profiles with weight 3x and 5x respectively and verify the combined output
RUN: llvm-profdata merge -sample -text -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=5,%p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s -check-prefix=3X_5X_WEIGHT
3X_5X_WEIGHT-DAG: foo:8816440:176635
3X_5X_WEIGHT-DAG: 7: 176635
3X_5X_WEIGHT-DAG: 8: 176635
3X_5X_WEIGHT-DAG: 9: 34650
3X_5X_WEIGHT-DAG: 10: 146705
3X_5X_WEIGHT-DAG: 11: 59530
3X_5X_WEIGHT-DAG: 13: 90925 foo:97655
3X_5X_WEIGHT-DAG: 15: 182290
3X_5X_WEIGHT-DAG: bar:5316111:106110
3X_5X_WEIGHT-DAG: 17: 106110
3X_5X_WEIGHT-DAG: 18: 106110
3X_5X_WEIGHT-DAG: 19: 21015
3X_5X_WEIGHT-DAG: 20: 88221
3X_5X_WEIGHT-DAG: 21: 36510
3X_5X_WEIGHT-DAG: 23: 54450 bar:59487
3X_5X_WEIGHT-DAG: 25: 109998
3- Bad merge: invalid weight
RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=0,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT
RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=0.75,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT
RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=-5,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT
RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT
RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=%p/Inputs/weight-sample-foo.proftext -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 -sample -weighted-input=3,%p/Inputs/does-not-exist.proftext -weighted-input=2,%p/Inputs/does-not-exist-either.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_INPUT
INVALID_INPUT: {{.*}}: {{.*}}does-not-exist.proftext: {{[Nn]}}o such file or directory
5- No inputs
RUN: not llvm-profdata merge -sample -o %t.out 2>&1 | FileCheck %s -check-prefix=NO_INPUT
NO_INPUT: {{.*}}: No input files specified. See llvm-profdata{{(\.EXE|\.exe)?}} merge -help