forked from OSchip/llvm-project
[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
This commit is contained in:
parent
66f6b65fed
commit
66703ebfe5
|
@ -0,0 +1,4 @@
|
|||
struct A {
|
||||
virtual int foo() { return 1; };
|
||||
virtual int bar();
|
||||
};
|
|
@ -0,0 +1,7 @@
|
|||
#include "instrprof-icall-promo.h"
|
||||
|
||||
A a;
|
||||
|
||||
A* ap = &a;
|
||||
|
||||
int ref(A* ap) { return ap->A::foo(); }
|
|
@ -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;
|
||||
}
|
|
@ -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
|
||||
|
Loading…
Reference in New Issue