etc/services - sync with NetBSD-8
[minix.git] / external / bsd / llvm / dist / clang / test / Profile / cxx-class.cpp
blob21cbbd68320a408f406bb74feb9885c10a0c1027
1 // Tests for instrumentation of C++ methods, constructors, and destructors.
3 // RUN: %clang %s -o - -emit-llvm -S -fprofile-instr-generate -fno-exceptions -target %itanium_abi_triple > %tgen
4 // RUN: FileCheck --input-file=%tgen -check-prefix=CTRGEN %s
5 // RUN: FileCheck --input-file=%tgen -check-prefix=DTRGEN %s
6 // RUN: FileCheck --input-file=%tgen -check-prefix=MTHGEN %s
7 // RUN: FileCheck --input-file=%tgen -check-prefix=WRPGEN %s
9 // RUN: llvm-profdata merge %S/Inputs/cxx-class.proftext -o %t.profdata
10 // RUN: %clang %s -o - -emit-llvm -S -fprofile-instr-use=%t.profdata -fno-exceptions -target %itanium_abi_triple > %tuse
11 // RUN: FileCheck --input-file=%tuse -check-prefix=CTRUSE %s
12 // RUN: FileCheck --input-file=%tuse -check-prefix=DTRUSE %s
13 // RUN: FileCheck --input-file=%tuse -check-prefix=MTHUSE %s
14 // RUN: FileCheck --input-file=%tuse -check-prefix=WRPUSE %s
16 class Simple {
17 int Member;
18 public:
19 // CTRGEN-LABEL: define {{.*}} @_ZN6SimpleC2Ei(
20 // CTRUSE-LABEL: define {{.*}} @_ZN6SimpleC2Ei(
21 // CTRGEN: store {{.*}} @[[SCC:__llvm_profile_counters__ZN6SimpleC2Ei]], i64 0, i64 0
22 explicit Simple(int Member) : Member(Member) {
23 // CTRGEN: store {{.*}} @[[SCC]], i64 0, i64 1
24 // CTRUSE: br {{.*}} !prof ![[SC1:[0-9]+]]
25 if (Member) {}
26 // CTRGEN-NOT: store {{.*}} @[[SCC]],
27 // CTRUSE-NOT: br {{.*}} !prof ![0-9]+
28 // CTRUSE: ret
30 // CTRUSE: ![[SC1]] = !{!"branch_weights", i32 100, i32 2}
32 // DTRGEN-LABEL: define {{.*}} @_ZN6SimpleD2Ev(
33 // DTRUSE-LABEL: define {{.*}} @_ZN6SimpleD2Ev(
34 // DTRGEN: store {{.*}} @[[SDC:__llvm_profile_counters__ZN6SimpleD2Ev]], i64 0, i64 0
35 ~Simple() {
36 // DTRGEN: store {{.*}} @[[SDC]], i64 0, i64 1
37 // DTRUSE: br {{.*}} !prof ![[SD1:[0-9]+]]
38 if (Member) {}
39 // DTRGEN-NOT: store {{.*}} @[[SDC]],
40 // DTRUSE-NOT: br {{.*}} !prof ![0-9]+
41 // DTRUSE: ret
43 // DTRUSE: ![[SD1]] = !{!"branch_weights", i32 100, i32 2}
45 // MTHGEN-LABEL: define {{.*}} @_ZN6Simple6methodEv(
46 // MTHUSE-LABEL: define {{.*}} @_ZN6Simple6methodEv(
47 // MTHGEN: store {{.*}} @[[SMC:__llvm_profile_counters__ZN6Simple6methodEv]], i64 0, i64 0
48 void method() {
49 // MTHGEN: store {{.*}} @[[SMC]], i64 0, i64 1
50 // MTHUSE: br {{.*}} !prof ![[SM1:[0-9]+]]
51 if (Member) {}
52 // MTHGEN-NOT: store {{.*}} @[[SMC]],
53 // MTHUSE-NOT: br {{.*}} !prof ![0-9]+
54 // MTHUSE: ret
56 // MTHUSE: ![[SM1]] = !{!"branch_weights", i32 100, i32 2}
59 // WRPGEN-LABEL: define {{.*}} @_Z14simple_wrapperv(
60 // WRPUSE-LABEL: define {{.*}} @_Z14simple_wrapperv(
61 // WRPGEN: store {{.*}} @[[SWC:__llvm_profile_counters__Z14simple_wrapperv]], i64 0, i64 0
62 void simple_wrapper() {
63 // WRPGEN: store {{.*}} @[[SWC]], i64 0, i64 1
64 // WRPUSE: br {{.*}} !prof ![[SW1:[0-9]+]]
65 for (int I = 0; I < 100; ++I) {
66 Simple S(I);
67 S.method();
69 // WRPGEN-NOT: store {{.*}} @[[SWC]],
70 // WRPUSE-NOT: br {{.*}} !prof ![0-9]+
71 // WRPUSE: ret
73 // WRPUSE: ![[SW1]] = !{!"branch_weights", i32 101, i32 2}
75 int main(int argc, const char *argv[]) {
76 simple_wrapper();
77 return 0;