diff options
author | Xinliang David Li <davidxl@google.com> | 2016-06-02 16:24:21 +0000 |
---|---|---|
committer | Xinliang David Li <davidxl@google.com> | 2016-06-02 16:24:21 +0000 |
commit | e151fbe8a11f85f4b0577ab3d27ef5254c3c4f74 (patch) | |
tree | 61c6f08e849b38584cc083452bc7254529884386 /test | |
parent | 77170c97c89da5daad5983220c35adb2fb56a981 (diff) |
[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)
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@271528 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/profile/Inputs/instrprof-icall-promo.h | 4 | ||||
-rw-r--r-- | test/profile/Inputs/instrprof-icall-promo_1.cc | 7 | ||||
-rw-r--r-- | test/profile/Inputs/instrprof-icall-promo_2.cc | 15 | ||||
-rw-r--r-- | test/profile/instrprof-icall-promo.test | 17 |
4 files changed, 43 insertions, 0 deletions
diff --git a/test/profile/Inputs/instrprof-icall-promo.h b/test/profile/Inputs/instrprof-icall-promo.h new file mode 100644 index 000000000..531e8ac82 --- /dev/null +++ b/test/profile/Inputs/instrprof-icall-promo.h @@ -0,0 +1,4 @@ +struct A { + virtual int foo() { return 1; }; + virtual int bar(); +}; diff --git a/test/profile/Inputs/instrprof-icall-promo_1.cc b/test/profile/Inputs/instrprof-icall-promo_1.cc new file mode 100644 index 000000000..e0a5e0693 --- /dev/null +++ b/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/test/profile/Inputs/instrprof-icall-promo_2.cc b/test/profile/Inputs/instrprof-icall-promo_2.cc new file mode 100644 index 000000000..658ab0bf4 --- /dev/null +++ b/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/test/profile/instrprof-icall-promo.test b/test/profile/instrprof-icall-promo.test new file mode 100644 index 000000000..8be50bca6 --- /dev/null +++ b/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 + |