summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2016-06-02 16:24:21 +0000
committerXinliang David Li <davidxl@google.com>2016-06-02 16:24:21 +0000
commit66703ebfe5a6f130365988344b1f2d33892ec64f (patch)
tree3a9a5e0a519f206b9d9bc0992d010431690391d1
parent66f6b65fed8e327954ca3c1370fb1fb206f219d7 (diff)
downloadbcm5719-llvm-66703ebfe5a6f130365988344b1f2d33892ec64f.tar.gz
bcm5719-llvm-66703ebfe5a6f130365988344b1f2d33892ec64f.zip
[profile] Add end-end test of vp for inline virtual functions
Make sure inline virtual function's address is properly recorded and dumped in raw profile so that value profiling does not loss tracking. (Second part of the test will be enabled after the lowering bug is fixed in LLVM) llvm-svn: 271528
-rw-r--r--compiler-rt/test/profile/Inputs/instrprof-icall-promo.h4
-rw-r--r--compiler-rt/test/profile/Inputs/instrprof-icall-promo_1.cc7
-rw-r--r--compiler-rt/test/profile/Inputs/instrprof-icall-promo_2.cc15
-rw-r--r--compiler-rt/test/profile/instrprof-icall-promo.test17
4 files changed, 43 insertions, 0 deletions
diff --git a/compiler-rt/test/profile/Inputs/instrprof-icall-promo.h b/compiler-rt/test/profile/Inputs/instrprof-icall-promo.h
new file mode 100644
index 00000000000..531e8ac82da
--- /dev/null
+++ b/compiler-rt/test/profile/Inputs/instrprof-icall-promo.h
@@ -0,0 +1,4 @@
+struct A {
+ virtual int foo() { return 1; };
+ virtual int bar();
+};
diff --git a/compiler-rt/test/profile/Inputs/instrprof-icall-promo_1.cc b/compiler-rt/test/profile/Inputs/instrprof-icall-promo_1.cc
new file mode 100644
index 00000000000..e0a5e069347
--- /dev/null
+++ b/compiler-rt/test/profile/Inputs/instrprof-icall-promo_1.cc
@@ -0,0 +1,7 @@
+#include "instrprof-icall-promo.h"
+
+A a;
+
+A* ap = &a;
+
+int ref(A* ap) { return ap->A::foo(); }
diff --git a/compiler-rt/test/profile/Inputs/instrprof-icall-promo_2.cc b/compiler-rt/test/profile/Inputs/instrprof-icall-promo_2.cc
new file mode 100644
index 00000000000..658ab0bf44d
--- /dev/null
+++ b/compiler-rt/test/profile/Inputs/instrprof-icall-promo_2.cc
@@ -0,0 +1,15 @@
+#include "instrprof-icall-promo.h"
+extern int ref(A *);
+
+int A::bar() { return 2; }
+
+extern A *ap;
+int test() {
+ for (int i = 0; i < 10000; i++) ap->foo();
+ return ref(ap);
+}
+
+int main() {
+ test();
+ return 0;
+}
diff --git a/compiler-rt/test/profile/instrprof-icall-promo.test b/compiler-rt/test/profile/instrprof-icall-promo.test
new file mode 100644
index 00000000000..8be50bca644
--- /dev/null
+++ b/compiler-rt/test/profile/instrprof-icall-promo.test
@@ -0,0 +1,17 @@
+RUN: %clangxx_profgen -O2 -Xclang -fprofile-instrument=llvm -c -o %t.1.o %S/Inputs/instrprof-icall-promo_1.cc
+RUN: %clangxx_profgen -O2 -Xclang -fprofile-instrument=llvm -c -o %t.2.o %S/Inputs/instrprof-icall-promo_2.cc
+
+RUN: %clangxx_profgen -O2 -Xclang -fprofile-instrument=llvm %t.2.o %t.1.o -o %t.gen.1
+RUN: LLVM_PROFILE_FILE=%t-icall.profraw %t.gen.1
+RUN: llvm-profdata merge -o %t-icall.profdata %t-icall.profraw
+RUN: %clangxx -O2 -Rpass=pgo-icall-prom -fprofile-instr-use=%t-icall.profdata -c -o %t.2.use.o %S/Inputs/instrprof-icall-promo_2.cc 2>&1 | FileCheck %s
+
+RUN: %clangxx_profgen -O2 -Xclang -fprofile-instrument=llvm %t.1.o %t.2.o -o %t.gen.2
+RUN: LLVM_PROFILE_FILE=%t-icall2.profraw %t.gen.2
+RUN: llvm-profdata merge -o %t-icall2.profdata %t-icall2.profraw
+# The following test will be re-enabled once a compiler bug is fixed.
+#: %clangxx -O2 -Rpass=pgo-icall-prom -fprofile-instr-use=%t-icall2.profdata -c -o %t.2.use.o %S/Inputs/instrprof-icall-promo_2.cc 2>&1 | FileCheck %s
+
+
+# CHECK: Promote indirect call to
+
OpenPOWER on IntegriCloud