2014-03-11 12:37:49 +08:00
|
|
|
// Tests for instrumentation of C++ methods, constructors, and destructors.
|
2014-01-23 10:54:27 +08:00
|
|
|
|
2016-04-23 10:11:16 +08:00
|
|
|
// RUN: %clang_cc1 %s -o - -emit-llvm -fprofile-instrument=clang -triple %itanium_abi_triple > %tgen
|
2014-01-23 10:54:27 +08:00
|
|
|
// RUN: FileCheck --input-file=%tgen -check-prefix=CTRGEN %s
|
|
|
|
// RUN: FileCheck --input-file=%tgen -check-prefix=DTRGEN %s
|
|
|
|
// RUN: FileCheck --input-file=%tgen -check-prefix=MTHGEN %s
|
|
|
|
// RUN: FileCheck --input-file=%tgen -check-prefix=WRPGEN %s
|
2017-02-24 09:15:19 +08:00
|
|
|
// RUN: FileCheck --input-file=%tgen -check-prefix=VCTRGEN %s
|
|
|
|
// RUN: FileCheck --input-file=%tgen -check-prefix=VDTRGEN %s
|
2014-01-23 10:54:27 +08:00
|
|
|
|
2014-04-18 06:49:06 +08:00
|
|
|
// RUN: llvm-profdata merge %S/Inputs/cxx-class.proftext -o %t.profdata
|
2016-04-23 10:11:16 +08:00
|
|
|
// RUN: %clang_cc1 %s -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata -triple %itanium_abi_triple > %tuse
|
2014-01-23 10:54:27 +08:00
|
|
|
// RUN: FileCheck --input-file=%tuse -check-prefix=CTRUSE %s
|
|
|
|
// RUN: FileCheck --input-file=%tuse -check-prefix=DTRUSE %s
|
|
|
|
// RUN: FileCheck --input-file=%tuse -check-prefix=MTHUSE %s
|
|
|
|
// RUN: FileCheck --input-file=%tuse -check-prefix=WRPUSE %s
|
2017-02-24 09:15:19 +08:00
|
|
|
// RUN: FileCheck --input-file=%tuse -check-prefix=VCTRUSE %s
|
|
|
|
// RUN: FileCheck --input-file=%tuse -check-prefix=VDTRUSE %s
|
2014-01-23 10:54:27 +08:00
|
|
|
|
|
|
|
class Simple {
|
|
|
|
public:
|
2017-02-24 09:15:19 +08:00
|
|
|
int Member;
|
2014-01-23 10:54:27 +08:00
|
|
|
// CTRGEN-LABEL: define {{.*}} @_ZN6SimpleC2Ei(
|
|
|
|
// CTRUSE-LABEL: define {{.*}} @_ZN6SimpleC2Ei(
|
2015-12-15 08:33:12 +08:00
|
|
|
// CTRGEN: store {{.*}} @[[SCC:__profc__ZN6SimpleC2Ei]], i64 0, i64 0
|
2014-01-23 10:54:27 +08:00
|
|
|
explicit Simple(int Member) : Member(Member) {
|
|
|
|
// CTRGEN: store {{.*}} @[[SCC]], i64 0, i64 1
|
|
|
|
// CTRUSE: br {{.*}} !prof ![[SC1:[0-9]+]]
|
|
|
|
if (Member) {}
|
|
|
|
// CTRGEN-NOT: store {{.*}} @[[SCC]],
|
|
|
|
// CTRUSE-NOT: br {{.*}} !prof ![0-9]+
|
2014-01-23 12:41:06 +08:00
|
|
|
// CTRUSE: ret
|
2014-01-23 10:54:27 +08:00
|
|
|
}
|
2014-12-16 03:10:08 +08:00
|
|
|
// CTRUSE: ![[SC1]] = !{!"branch_weights", i32 100, i32 2}
|
2014-01-23 10:54:27 +08:00
|
|
|
|
|
|
|
// DTRGEN-LABEL: define {{.*}} @_ZN6SimpleD2Ev(
|
|
|
|
// DTRUSE-LABEL: define {{.*}} @_ZN6SimpleD2Ev(
|
2015-12-15 08:33:12 +08:00
|
|
|
// DTRGEN: store {{.*}} @[[SDC:__profc__ZN6SimpleD2Ev]], i64 0, i64 0
|
2014-01-23 10:54:27 +08:00
|
|
|
~Simple() {
|
|
|
|
// DTRGEN: store {{.*}} @[[SDC]], i64 0, i64 1
|
|
|
|
// DTRUSE: br {{.*}} !prof ![[SD1:[0-9]+]]
|
|
|
|
if (Member) {}
|
|
|
|
// DTRGEN-NOT: store {{.*}} @[[SDC]],
|
|
|
|
// DTRUSE-NOT: br {{.*}} !prof ![0-9]+
|
2014-01-23 12:41:06 +08:00
|
|
|
// DTRUSE: ret
|
2014-01-23 10:54:27 +08:00
|
|
|
}
|
2014-12-16 03:10:08 +08:00
|
|
|
// DTRUSE: ![[SD1]] = !{!"branch_weights", i32 100, i32 2}
|
2014-01-23 10:54:27 +08:00
|
|
|
|
|
|
|
// MTHGEN-LABEL: define {{.*}} @_ZN6Simple6methodEv(
|
|
|
|
// MTHUSE-LABEL: define {{.*}} @_ZN6Simple6methodEv(
|
2015-12-15 08:33:12 +08:00
|
|
|
// MTHGEN: store {{.*}} @[[SMC:__profc__ZN6Simple6methodEv]], i64 0, i64 0
|
2014-01-23 10:54:27 +08:00
|
|
|
void method() {
|
|
|
|
// MTHGEN: store {{.*}} @[[SMC]], i64 0, i64 1
|
|
|
|
// MTHUSE: br {{.*}} !prof ![[SM1:[0-9]+]]
|
|
|
|
if (Member) {}
|
|
|
|
// MTHGEN-NOT: store {{.*}} @[[SMC]],
|
|
|
|
// MTHUSE-NOT: br {{.*}} !prof ![0-9]+
|
2014-01-23 12:41:06 +08:00
|
|
|
// MTHUSE: ret
|
2014-01-23 10:54:27 +08:00
|
|
|
}
|
2014-12-16 03:10:08 +08:00
|
|
|
// MTHUSE: ![[SM1]] = !{!"branch_weights", i32 100, i32 2}
|
2014-01-23 10:54:27 +08:00
|
|
|
};
|
|
|
|
|
2017-02-24 09:15:19 +08:00
|
|
|
class Derived : virtual public Simple {
|
|
|
|
public:
|
|
|
|
// VCTRGEN-LABEL: define {{.*}} @_ZN7DerivedC1Ev(
|
|
|
|
// VCTRUSE-LABEL: define {{.*}} @_ZN7DerivedC1Ev(
|
|
|
|
// VCTRGEN: store {{.*}} @[[SCC:__profc__ZN7DerivedC1Ev]], i64 0, i64 0
|
|
|
|
Derived() : Simple(0) {
|
|
|
|
// VCTRGEN: store {{.*}} @[[SCC]], i64 0, i64 1
|
|
|
|
// VCTRUSE: br {{.*}} !prof ![[SC1:[0-9]+]]
|
|
|
|
if (Member) {}
|
|
|
|
// VCTRGEN-NOT: store {{.*}} @[[SCC]],
|
|
|
|
// VCTRUSE-NOT: br {{.*}} !prof ![0-9]+
|
|
|
|
// VCTRUSE: ret
|
|
|
|
}
|
|
|
|
// VCTRUSE: ![[SC1]] = !{!"branch_weights", i32 100, i32 2}
|
|
|
|
|
|
|
|
// VDTRGEN-LABEL: define {{.*}} @_ZN7DerivedD2Ev(
|
|
|
|
// VDTRUSE-LABEL: define {{.*}} @_ZN7DerivedD2Ev(
|
|
|
|
// VDTRGEN: store {{.*}} @[[SDC:__profc__ZN7DerivedD2Ev]], i64 0, i64 0
|
|
|
|
~Derived() {
|
|
|
|
// VDTRGEN: store {{.*}} @[[SDC]], i64 0, i64 1
|
|
|
|
// VDTRUSE: br {{.*}} !prof ![[SD1:[0-9]+]]
|
|
|
|
if (Member) {}
|
|
|
|
// VDTRGEN-NOT: store {{.*}} @[[SDC]],
|
|
|
|
// VDTRUSE-NOT: br {{.*}} !prof ![0-9]+
|
|
|
|
// VDTRUSE: ret
|
|
|
|
}
|
|
|
|
// VDTRUSE: ![[SD1]] = !{!"branch_weights", i32 100, i32 2}
|
|
|
|
};
|
|
|
|
|
2014-01-23 10:54:27 +08:00
|
|
|
// WRPGEN-LABEL: define {{.*}} @_Z14simple_wrapperv(
|
|
|
|
// WRPUSE-LABEL: define {{.*}} @_Z14simple_wrapperv(
|
2015-12-15 08:33:12 +08:00
|
|
|
// WRPGEN: store {{.*}} @[[SWC:__profc__Z14simple_wrapperv]], i64 0, i64 0
|
2014-01-23 10:54:27 +08:00
|
|
|
void simple_wrapper() {
|
|
|
|
// WRPGEN: store {{.*}} @[[SWC]], i64 0, i64 1
|
|
|
|
// WRPUSE: br {{.*}} !prof ![[SW1:[0-9]+]]
|
|
|
|
for (int I = 0; I < 100; ++I) {
|
2017-02-24 09:15:19 +08:00
|
|
|
Derived d;
|
2014-01-23 10:54:27 +08:00
|
|
|
Simple S(I);
|
|
|
|
S.method();
|
|
|
|
}
|
|
|
|
// WRPGEN-NOT: store {{.*}} @[[SWC]],
|
|
|
|
// WRPUSE-NOT: br {{.*}} !prof ![0-9]+
|
2014-01-23 12:41:06 +08:00
|
|
|
// WRPUSE: ret
|
2014-01-23 10:54:27 +08:00
|
|
|
}
|
2014-12-16 03:10:08 +08:00
|
|
|
// WRPUSE: ![[SW1]] = !{!"branch_weights", i32 101, i32 2}
|
2014-01-23 10:54:27 +08:00
|
|
|
|
|
|
|
int main(int argc, const char *argv[]) {
|
|
|
|
simple_wrapper();
|
|
|
|
return 0;
|
|
|
|
}
|