summaryrefslogtreecommitdiff
path: root/test/profile
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2019-03-08 15:30:56 +0000
committerManman Ren <manman.ren@gmail.com>2019-03-08 15:30:56 +0000
commit3137e93cfd656fb907f6b357bb73c91f901e493a (patch)
tree05254bdd61eea440507d0956716a920280ca148e /test/profile
parent941c57171e2dc51b3f727117d46ee057bd309915 (diff)
downloadcompiler-rt-3137e93cfd656fb907f6b357bb73c91f901e493a.tar.gz
Reland compiler-rt support for order file instrumentation.
r355343 was landed and was reverted in r355363 due to build breakage. This patch adds Linux/Windows support on top of r355343. In this patch, Darwin should be working with testing case. Linux should be working, I will enable the testing case in a follwup diff. Windows/Other should be building. Correct implementation for Other platforms will be added. Thanks David for reviewing the original diff, helping me with issues on Linux, and giving suggestions for adding support for Other platforms. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355701 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/profile')
-rw-r--r--test/profile/Inputs/instrprof-order-file-2.c7
-rw-r--r--test/profile/Inputs/instrprof-order-file.c17
-rw-r--r--test/profile/instrprof-order-file.test17
3 files changed, 41 insertions, 0 deletions
diff --git a/test/profile/Inputs/instrprof-order-file-2.c b/test/profile/Inputs/instrprof-order-file-2.c
new file mode 100644
index 000000000..ee4485756
--- /dev/null
+++ b/test/profile/Inputs/instrprof-order-file-2.c
@@ -0,0 +1,7 @@
+__attribute__((noinline)) int f(int a) {
+ return a + 1;
+}
+
+__attribute__((noinline)) int g(int a) {
+ return a + 2;
+}
diff --git a/test/profile/Inputs/instrprof-order-file.c b/test/profile/Inputs/instrprof-order-file.c
new file mode 100644
index 000000000..9251a8e25
--- /dev/null
+++ b/test/profile/Inputs/instrprof-order-file.c
@@ -0,0 +1,17 @@
+void __llvm_profile_initialize_file(void);
+int __llvm_orderfile_dump(void);
+
+__attribute__((noinline)) int f(int a);
+
+__attribute__((noinline)) int g(int a);
+
+int main(int argc, const char *argv[]) {
+ int a = f(argc);
+ int t = 0;
+ for (int i = 0; i < argc; i++)
+ t += g(a);
+ f(t);
+ __llvm_profile_initialize_file();
+ __llvm_orderfile_dump();
+ return 0;
+}
diff --git a/test/profile/instrprof-order-file.test b/test/profile/instrprof-order-file.test
new file mode 100644
index 000000000..09e77d7f6
--- /dev/null
+++ b/test/profile/instrprof-order-file.test
@@ -0,0 +1,17 @@
+// UNSUPPORTED: windows
+// REQUIRES: darwin
+// RUN: rm -rf %t.dir && mkdir -p %t.dir
+// RUN: cd %t.dir
+//
+// RUN: %clang -forder-file-instrumentation -O1 -o %t.2 %S/Inputs/instrprof-order-file-2.c %S/Inputs/instrprof-order-file.c -mllvm -orderfile-write-mapping="mapping.txt"
+// RUN: %run %t.2 ANY
+// RUN: od -h default.profraw.order | FileCheck %s
+// RUN: cat mapping.txt | FileCheck %s --check-prefix=MAPPING
+
+// Make sure we have MD5 for main, then f, then g.
+// CHECK: 0000000 d5fa e78d 6436 db95 a18f dd4c 4f75 cc91
+// CHECK: 0000020 f5b2 47ff 6643 b671 0000 0000 0000 0000
+
+// MAPPING: MD5 cc914f75dd4ca18f f
+// MAPPING: MD5 b671664347fff5b2 g
+// MAPPING: MD5 db956436e78dd5fa main