summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-03-23 03:38:12 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-03-23 03:38:12 +0000
commit0695b20d9adb555b89eb4e095ce377ff8ae04eee (patch)
tree7d7f2039958ff9ee9c384d932354d5c03908e041 /test
parent4ff2dadebed5b428689bb6651b8f83688ce2d934 (diff)
downloadllvm-0695b20d9adb555b89eb4e095ce377ff8ae04eee.tar.gz
llvm-0695b20d9adb555b89eb4e095ce377ff8ae04eee.tar.bz2
llvm-0695b20d9adb555b89eb4e095ce377ff8ae04eee.tar.xz
InstrProf: Check pointer size in raw profile
Since the profile can come from 32-bit machines, we need to check the pointer size. Change the magic number to facilitate this. Adds tests for reading 32-bit and 64-bit binaries (both big- and little-endian). The tests write a binary using printf in RUN lines (like raw-magic-but-no-header.test). Assuming the bots don't complain, this seems like a better way forward for testing RawInstrProfReader than committing binary files. <rdar://problem/16400648> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204557 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/tools/llvm-profdata/raw-32-bits-be.test42
-rw-r--r--test/tools/llvm-profdata/raw-32-bits-le.test42
-rw-r--r--test/tools/llvm-profdata/raw-64-bits-be.test42
-rw-r--r--test/tools/llvm-profdata/raw-64-bits-le.test42
4 files changed, 168 insertions, 0 deletions
diff --git a/test/tools/llvm-profdata/raw-32-bits-be.test b/test/tools/llvm-profdata/raw-32-bits-be.test
new file mode 100644
index 0000000000..86ac56d39f
--- /dev/null
+++ b/test/tools/llvm-profdata/raw-32-bits-be.test
@@ -0,0 +1,42 @@
+RUN: printf '\377lprofR\201' > %t
+RUN: printf '\0\0\0\0\0\0\0\1' >> %t
+RUN: printf '\0\0\0\0\0\0\0\2' >> %t
+RUN: printf '\0\0\0\0\0\0\0\3' >> %t
+RUN: printf '\0\0\0\0\0\0\0\6' >> %t
+RUN: printf '\0\0\0\0\1\0\0\0' >> %t
+RUN: printf '\0\0\0\0\2\0\0\0' >> %t
+
+RUN: printf '\0\0\0\3' >> %t
+RUN: printf '\0\0\0\1' >> %t
+RUN: printf '\0\0\0\0\0\0\0\1' >> %t
+RUN: printf '\2\0\0\0' >> %t
+RUN: printf '\1\0\0\0' >> %t
+
+RUN: printf '\0\0\0\3' >> %t
+RUN: printf '\0\0\0\2' >> %t
+RUN: printf '\0\0\0\0\0\0\0\2' >> %t
+RUN: printf '\2\0\0\03' >> %t
+RUN: printf '\1\0\0\10' >> %t
+
+RUN: printf '\0\0\0\0\0\0\0\023' >> %t
+RUN: printf '\0\0\0\0\0\0\0\067' >> %t
+RUN: printf '\0\0\0\0\0\0\0\101' >> %t
+RUN: printf 'foobar' >> %t
+
+RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s
+
+CHECK: Counters:
+CHECK: foo:
+CHECK: Hash: 0x0000000000000001
+CHECK: Counters: 1
+CHECK: Function count: 19
+CHECK: Block counts: []
+CHECK: bar:
+CHECK: Hash: 0x0000000000000002
+CHECK: Counters: 2
+CHECK: Function count: 55
+CHECK: Block counts: [65]
+CHECK: Functions shown: 2
+CHECK: Total functions: 2
+CHECK: Maximum function count: 55
+CHECK: Maximum internal block count: 65
diff --git a/test/tools/llvm-profdata/raw-32-bits-le.test b/test/tools/llvm-profdata/raw-32-bits-le.test
new file mode 100644
index 0000000000..9325e7eb0f
--- /dev/null
+++ b/test/tools/llvm-profdata/raw-32-bits-le.test
@@ -0,0 +1,42 @@
+RUN: printf '\201Rforpl\377' > %t
+RUN: printf '\1\0\0\0\0\0\0\0' >> %t
+RUN: printf '\2\0\0\0\0\0\0\0' >> %t
+RUN: printf '\3\0\0\0\0\0\0\0' >> %t
+RUN: printf '\6\0\0\0\0\0\0\0' >> %t
+RUN: printf '\0\0\0\1\0\0\0\0' >> %t
+RUN: printf '\0\0\0\2\0\0\0\0' >> %t
+
+RUN: printf '\3\0\0\0' >> %t
+RUN: printf '\1\0\0\0' >> %t
+RUN: printf '\1\0\0\0\0\0\0\0' >> %t
+RUN: printf '\0\0\0\2' >> %t
+RUN: printf '\0\0\0\1' >> %t
+
+RUN: printf '\3\0\0\0' >> %t
+RUN: printf '\2\0\0\0' >> %t
+RUN: printf '\02\0\0\0\0\0\0\0' >> %t
+RUN: printf '\03\0\0\2' >> %t
+RUN: printf '\10\0\0\1' >> %t
+
+RUN: printf '\023\0\0\0\0\0\0\0' >> %t
+RUN: printf '\067\0\0\0\0\0\0\0' >> %t
+RUN: printf '\101\0\0\0\0\0\0\0' >> %t
+RUN: printf 'foobar' >> %t
+
+RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s
+
+CHECK: Counters:
+CHECK: foo:
+CHECK: Hash: 0x0000000000000001
+CHECK: Counters: 1
+CHECK: Function count: 19
+CHECK: Block counts: []
+CHECK: bar:
+CHECK: Hash: 0x0000000000000002
+CHECK: Counters: 2
+CHECK: Function count: 55
+CHECK: Block counts: [65]
+CHECK: Functions shown: 2
+CHECK: Total functions: 2
+CHECK: Maximum function count: 55
+CHECK: Maximum internal block count: 65
diff --git a/test/tools/llvm-profdata/raw-64-bits-be.test b/test/tools/llvm-profdata/raw-64-bits-be.test
new file mode 100644
index 0000000000..b97d8b5dac
--- /dev/null
+++ b/test/tools/llvm-profdata/raw-64-bits-be.test
@@ -0,0 +1,42 @@
+RUN: printf '\377lprofr\201' > %t
+RUN: printf '\0\0\0\0\0\0\0\1' >> %t
+RUN: printf '\0\0\0\0\0\0\0\2' >> %t
+RUN: printf '\0\0\0\0\0\0\0\3' >> %t
+RUN: printf '\0\0\0\0\0\0\0\6' >> %t
+RUN: printf '\0\0\0\1\0\4\0\0' >> %t
+RUN: printf '\0\0\0\2\0\4\0\0' >> %t
+
+RUN: printf '\0\0\0\3' >> %t
+RUN: printf '\0\0\0\1' >> %t
+RUN: printf '\0\0\0\0\0\0\0\1' >> %t
+RUN: printf '\0\0\0\2\0\4\0\0' >> %t
+RUN: printf '\0\0\0\1\0\4\0\0' >> %t
+
+RUN: printf '\0\0\0\3' >> %t
+RUN: printf '\0\0\0\2' >> %t
+RUN: printf '\0\0\0\0\0\0\0\02' >> %t
+RUN: printf '\0\0\0\2\0\4\0\03' >> %t
+RUN: printf '\0\0\0\1\0\4\0\10' >> %t
+
+RUN: printf '\0\0\0\0\0\0\0\023' >> %t
+RUN: printf '\0\0\0\0\0\0\0\067' >> %t
+RUN: printf '\0\0\0\0\0\0\0\101' >> %t
+RUN: printf 'foobar' >> %t
+
+RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s
+
+CHECK: Counters:
+CHECK: foo:
+CHECK: Hash: 0x0000000000000001
+CHECK: Counters: 1
+CHECK: Function count: 19
+CHECK: Block counts: []
+CHECK: bar:
+CHECK: Hash: 0x0000000000000002
+CHECK: Counters: 2
+CHECK: Function count: 55
+CHECK: Block counts: [65]
+CHECK: Functions shown: 2
+CHECK: Total functions: 2
+CHECK: Maximum function count: 55
+CHECK: Maximum internal block count: 65
diff --git a/test/tools/llvm-profdata/raw-64-bits-le.test b/test/tools/llvm-profdata/raw-64-bits-le.test
new file mode 100644
index 0000000000..0e6853811e
--- /dev/null
+++ b/test/tools/llvm-profdata/raw-64-bits-le.test
@@ -0,0 +1,42 @@
+RUN: printf '\201rforpl\377' > %t
+RUN: printf '\1\0\0\0\0\0\0\0' >> %t
+RUN: printf '\2\0\0\0\0\0\0\0' >> %t
+RUN: printf '\3\0\0\0\0\0\0\0' >> %t
+RUN: printf '\6\0\0\0\0\0\0\0' >> %t
+RUN: printf '\0\0\4\0\1\0\0\0' >> %t
+RUN: printf '\0\0\4\0\2\0\0\0' >> %t
+
+RUN: printf '\3\0\0\0' >> %t
+RUN: printf '\1\0\0\0' >> %t
+RUN: printf '\1\0\0\0\0\0\0\0' >> %t
+RUN: printf '\0\0\4\0\2\0\0\0' >> %t
+RUN: printf '\0\0\4\0\1\0\0\0' >> %t
+
+RUN: printf '\03\0\0\0' >> %t
+RUN: printf '\02\0\0\0' >> %t
+RUN: printf '\02\0\0\0\0\0\0\0' >> %t
+RUN: printf '\03\0\4\0\2\0\0\0' >> %t
+RUN: printf '\10\0\4\0\1\0\0\0' >> %t
+
+RUN: printf '\023\0\0\0\0\0\0\0' >> %t
+RUN: printf '\067\0\0\0\0\0\0\0' >> %t
+RUN: printf '\101\0\0\0\0\0\0\0' >> %t
+RUN: printf 'foobar' >> %t
+
+RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s
+
+CHECK: Counters:
+CHECK: foo:
+CHECK: Hash: 0x0000000000000001
+CHECK: Counters: 1
+CHECK: Function count: 19
+CHECK: Block counts: []
+CHECK: bar:
+CHECK: Hash: 0x0000000000000002
+CHECK: Counters: 2
+CHECK: Function count: 55
+CHECK: Block counts: [65]
+CHECK: Functions shown: 2
+CHECK: Total functions: 2
+CHECK: Maximum function count: 55
+CHECK: Maximum internal block count: 65