summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/tools/llvm-profdata/Inputs/weight-instr-bar.profdatabin0 -> 1320 bytes
-rw-r--r--llvm/test/tools/llvm-profdata/Inputs/weight-instr-foo.profdatabin0 -> 1320 bytes
-rw-r--r--llvm/test/tools/llvm-profdata/Inputs/weight-sample-bar.proftext8
-rw-r--r--llvm/test/tools/llvm-profdata/Inputs/weight-sample-foo.proftext8
-rw-r--r--llvm/test/tools/llvm-profdata/text-format-errors.test2
-rw-r--r--llvm/test/tools/llvm-profdata/weight-instr.test69
-rw-r--r--llvm/test/tools/llvm-profdata/weight-sample.test56
7 files changed, 142 insertions, 1 deletions
diff --git a/llvm/test/tools/llvm-profdata/Inputs/weight-instr-bar.profdata b/llvm/test/tools/llvm-profdata/Inputs/weight-instr-bar.profdata
new file mode 100644
index 00000000000..4ed07660f65
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/Inputs/weight-instr-bar.profdata
Binary files differ
diff --git a/llvm/test/tools/llvm-profdata/Inputs/weight-instr-foo.profdata b/llvm/test/tools/llvm-profdata/Inputs/weight-instr-foo.profdata
new file mode 100644
index 00000000000..581ef39a55b
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/Inputs/weight-instr-foo.profdata
Binary files differ
diff --git a/llvm/test/tools/llvm-profdata/Inputs/weight-sample-bar.proftext b/llvm/test/tools/llvm-profdata/Inputs/weight-sample-bar.proftext
new file mode 100644
index 00000000000..a910f745e6c
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/Inputs/weight-sample-bar.proftext
@@ -0,0 +1,8 @@
+bar:1772037:35370
+ 17: 35370
+ 18: 35370
+ 19: 7005
+ 20: 29407
+ 21: 12170
+ 23: 18150 bar:19829
+ 25: 36666
diff --git a/llvm/test/tools/llvm-profdata/Inputs/weight-sample-foo.proftext b/llvm/test/tools/llvm-profdata/Inputs/weight-sample-foo.proftext
new file mode 100644
index 00000000000..155ec5d0031
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/Inputs/weight-sample-foo.proftext
@@ -0,0 +1,8 @@
+foo:1763288:35327
+ 7: 35327
+ 8: 35327
+ 9: 6930
+ 10: 29341
+ 11: 11906
+ 13: 18185 foo:19531
+ 15: 36458
diff --git a/llvm/test/tools/llvm-profdata/text-format-errors.test b/llvm/test/tools/llvm-profdata/text-format-errors.test
index b300586d102..05de2e38af1 100644
--- a/llvm/test/tools/llvm-profdata/text-format-errors.test
+++ b/llvm/test/tools/llvm-profdata/text-format-errors.test
@@ -2,7 +2,7 @@ Tests for instrumentation profile bad encoding.
1- Detect invalid count
RUN: not llvm-profdata show %p/Inputs/invalid-count-later.proftext 2>&1 | FileCheck %s --check-prefix=INVALID-COUNT-LATER
-RUN: not llvm-profdata merge %p/Inputs/invalid-count-later.proftext %p/Inputs/invalid-count-later.profdata -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID-COUNT-LATER
+RUN: not llvm-profdata merge %p/Inputs/invalid-count-later.proftext %p/Inputs/invalid-count-later.proftext -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID-COUNT-LATER
INVALID-COUNT-LATER: error: {{.*}}invalid-count-later.proftext: Malformed instrumentation profile data
2- Detect bad hash
diff --git a/llvm/test/tools/llvm-profdata/weight-instr.test b/llvm/test/tools/llvm-profdata/weight-instr.test
new file mode 100644
index 00000000000..7294cf3b01f
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/weight-instr.test
@@ -0,0 +1,69 @@
+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 -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 -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: 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
diff --git a/llvm/test/tools/llvm-profdata/weight-sample.test b/llvm/test/tools/llvm-profdata/weight-sample.test
new file mode 100644
index 00000000000..7b22c5f88f1
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/weight-sample.test
@@ -0,0 +1,56 @@
+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: foo:1763288:35327
+1X_1X_WEIGHT-NEXT: 7: 35327
+1X_1X_WEIGHT-NEXT: 8: 35327
+1X_1X_WEIGHT-NEXT: 9: 6930
+1X_1X_WEIGHT-NEXT: 10: 29341
+1X_1X_WEIGHT-NEXT: 11: 11906
+1X_1X_WEIGHT-NEXT: 13: 18185 foo:19531
+1X_1X_WEIGHT-NEXT: 15: 36458
+1X_1X_WEIGHT-NEXT: bar:1772037:35370
+1X_1X_WEIGHT-NEXT: 17: 35370
+1X_1X_WEIGHT-NEXT: 18: 35370
+1X_1X_WEIGHT-NEXT: 19: 7005
+1X_1X_WEIGHT-NEXT: 20: 29407
+1X_1X_WEIGHT-NEXT: 21: 12170
+1X_1X_WEIGHT-NEXT: 23: 18150 bar:19829
+1X_1X_WEIGHT-NEXT: 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: foo:8816440:176635
+3X_5X_WEIGHT-NEXT: 7: 176635
+3X_5X_WEIGHT-NEXT: 8: 176635
+3X_5X_WEIGHT-NEXT: 9: 34650
+3X_5X_WEIGHT-NEXT: 10: 146705
+3X_5X_WEIGHT-NEXT: 11: 59530
+3X_5X_WEIGHT-NEXT: 13: 90925 foo:97655
+3X_5X_WEIGHT-NEXT: 15: 182290
+3X_5X_WEIGHT-NEXT: bar:5316111:106110
+3X_5X_WEIGHT-NEXT: 17: 106110
+3X_5X_WEIGHT-NEXT: 18: 106110
+3X_5X_WEIGHT-NEXT: 19: 21015
+3X_5X_WEIGHT-NEXT: 20: 88221
+3X_5X_WEIGHT-NEXT: 21: 36510
+3X_5X_WEIGHT-NEXT: 23: 54450 bar:59487
+3X_5X_WEIGHT-NEXT: 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
OpenPOWER on IntegriCloud