summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/llvm-profdata
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-08-01 22:50:07 +0000
committerJustin Bogner <mail@justinbogner.com>2014-08-01 22:50:07 +0000
commit821d7471f91858ce91de86df940cedfab4166543 (patch)
tree2fcdad0febecb3f9cac05d44dad329d0759b64a9 /llvm/test/tools/llvm-profdata
parent6d3adac2179bc7867f55d108111ec38877b8b7c0 (diff)
downloadbcm5719-llvm-821d7471f91858ce91de86df940cedfab4166543.tar.gz
bcm5719-llvm-821d7471f91858ce91de86df940cedfab4166543.zip
InstrProf: Allow multiple functions with the same name
This updates the instrumentation based profiling format so that when we have multiple functions with the same name (but different function hashes) we keep all of them instead of rejecting the later ones. There are a number of scenarios where this can come up where it's more useful to keep multiple function profiles: * Name collisions in unrelated libraries that are profiled together. * Multiple "main" functions from multiple tools built against a common library. * Combining profiles from different build configurations (ie, asserts and no-asserts) The profile format now stores the number of counters between the hash and the counts themselves, so that multiple sets of counts can be stored. Since this is backwards incompatible, I've bumped the format version and added some trivial logic to skip this when reading the old format. llvm-svn: 214585
Diffstat (limited to 'llvm/test/tools/llvm-profdata')
-rw-r--r--llvm/test/tools/llvm-profdata/Inputs/compat.profdata.v1bin0 -> 792 bytes
-rw-r--r--llvm/test/tools/llvm-profdata/compat.proftext47
-rw-r--r--llvm/test/tools/llvm-profdata/hash-mismatch.proftext24
3 files changed, 69 insertions, 2 deletions
diff --git a/llvm/test/tools/llvm-profdata/Inputs/compat.profdata.v1 b/llvm/test/tools/llvm-profdata/Inputs/compat.profdata.v1
new file mode 100644
index 00000000000..fd17459d091
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/Inputs/compat.profdata.v1
Binary files differ
diff --git a/llvm/test/tools/llvm-profdata/compat.proftext b/llvm/test/tools/llvm-profdata/compat.proftext
new file mode 100644
index 00000000000..14da3374b5e
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/compat.proftext
@@ -0,0 +1,47 @@
+# Compatibility tests for older profile format versions. These ensure
+# that we don't break compatibility with an older profile version
+# without noticing it.
+
+# The input file at %S/Inputs/compat.profdata.v1 was generated with
+# llvm-profdata merge from r214548.
+
+# RUN: llvm-profdata show %S/Inputs/compat.profdata.v1 --function function_count_only --counts | FileCheck %s -check-prefix=FUNC_COUNT_ONLY
+function_count_only
+0
+1
+97531
+# FUNC_COUNT_ONLY: Hash: 0x{{0+$}}
+# FUNC_COUNT_ONLY-NEXT: Counters: 1
+# FUNC_COUNT_ONLY-NEXT: Function count: 97531
+# FUNC_COUNT_ONLY-NEXT: Block counts: []
+
+# RUN: llvm-profdata show %S/Inputs/compat.profdata.v1 --function "name with spaces" --counts | FileCheck %s -check-prefix=SPACES
+name with spaces
+1024
+2
+0
+0
+# SPACES: Hash: 0x{{0+}}400
+# SPACES-NEXT: Counters: 2
+# SPACES-NEXT: Function count: 0
+# SPACES-NEXT: Block counts: [0]
+
+# RUN: llvm-profdata show %S/Inputs/compat.profdata.v1 --function large_numbers --counts | FileCheck %s -check-prefix=LARGENUM
+large_numbers
+4611686018427387903
+6
+2305843009213693952
+1152921504606846976
+576460752303423488
+288230376151711744
+144115188075855872
+72057594037927936
+# LARGENUM: Hash: 0x3fffffffffffffff
+# LARGENUM-NEXT: Counters: 6
+# LARGENUM-NEXT: Function count: 2305843009213693952
+# LARGENUM-NEXT: Block counts: [1152921504606846976, 576460752303423488, 288230376151711744, 144115188075855872, 72057594037927936]
+
+# RUN: llvm-profdata show %S/Inputs/compat.profdata.v1 | FileCheck %s -check-prefix=SUMMARY
+# SUMMARY: Total functions: 3
+# SUMMARY: Maximum function count: 2305843009213693952
+# SUMMARY: Maximum internal block count: 1152921504606846976
diff --git a/llvm/test/tools/llvm-profdata/hash-mismatch.proftext b/llvm/test/tools/llvm-profdata/hash-mismatch.proftext
index e4f1a4ca431..fe0d4fb4f6b 100644
--- a/llvm/test/tools/llvm-profdata/hash-mismatch.proftext
+++ b/llvm/test/tools/llvm-profdata/hash-mismatch.proftext
@@ -1,6 +1,18 @@
-# RUN: llvm-profdata merge %s -o %t.out 2>&1 | FileCheck %s
-# CHECK: hash-mismatch.proftext: foo: Function hash mismatch
+# If we see the same function name, but with different hashes, make
+# sure we keep both.
+# RUN: llvm-profdata merge %s -o %t 2>&1
+# RUN: llvm-profdata show %t -all-functions -counts > %t.out
+
+# The function ordering is non-deterministic, so we need to do our
+# checks in multiple runs.
+# RUN: FileCheck -check-prefix=FOO3 -check-prefix=BOTH %s -input-file %t.out
+# RUN: FileCheck -check-prefix=FOO4 -check-prefix=BOTH %s -input-file %t.out
+
+# FOO3: Hash: 0x{{0+}}3
+# FOO3-NEXT: Counters: 3
+# FOO3-NEXT: Function count: 1
+# FOO3-NEXT: Block counts: [2, 3]
foo
3
3
@@ -8,6 +20,10 @@ foo
2
3
+# FOO4: Hash: 0x{{0+}}4
+# FOO4-NEXT: Counters: 4
+# FOO4-NEXT: Function count: 11
+# FOO4-NEXT: Block counts: [22, 33, 44]
foo
4
4
@@ -15,3 +31,7 @@ foo
22
33
44
+
+# BOTH: Total functions: 2
+# BOTH: Maximum function count: 11
+# BOTH: Maximum internal block count: 44
OpenPOWER on IntegriCloud