Justin Bogner | 52a6a97 | 2014-03-11 04:37:49 +0000 | [diff] [blame^] | 1 | // Tests for instrumentation of C++ methods, constructors, and destructors. |
Justin Bogner | 81c22c2 | 2014-01-23 02:54:27 +0000 | [diff] [blame] | 2 | |
| 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 |
| 8 | |
Justin Bogner | 52a6a97 | 2014-03-11 04:37:49 +0000 | [diff] [blame^] | 9 | // RUN: %clang %s -o - -emit-llvm -S -fprofile-instr-use=%S/Inputs/cxx-class.profdata -fno-exceptions -target %itanium_abi_triple > %tuse |
Justin Bogner | 81c22c2 | 2014-01-23 02:54:27 +0000 | [diff] [blame] | 10 | // RUN: FileCheck --input-file=%tuse -check-prefix=CTRUSE %s |
| 11 | // RUN: FileCheck --input-file=%tuse -check-prefix=DTRUSE %s |
| 12 | // RUN: FileCheck --input-file=%tuse -check-prefix=MTHUSE %s |
| 13 | // RUN: FileCheck --input-file=%tuse -check-prefix=WRPUSE %s |
| 14 | |
| 15 | class Simple { |
| 16 | int Member; |
| 17 | public: |
| 18 | // CTRGEN-LABEL: define {{.*}} @_ZN6SimpleC2Ei( |
| 19 | // CTRUSE-LABEL: define {{.*}} @_ZN6SimpleC2Ei( |
| 20 | // CTRGEN: store {{.*}} @[[SCC:__llvm_pgo_ctr[0-9]*]], i64 0, i64 0 |
| 21 | explicit Simple(int Member) : Member(Member) { |
| 22 | // CTRGEN: store {{.*}} @[[SCC]], i64 0, i64 1 |
| 23 | // CTRUSE: br {{.*}} !prof ![[SC1:[0-9]+]] |
| 24 | if (Member) {} |
| 25 | // CTRGEN-NOT: store {{.*}} @[[SCC]], |
| 26 | // CTRUSE-NOT: br {{.*}} !prof ![0-9]+ |
Justin Bogner | 49e453f | 2014-01-23 04:41:06 +0000 | [diff] [blame] | 27 | // CTRUSE: ret |
Justin Bogner | 81c22c2 | 2014-01-23 02:54:27 +0000 | [diff] [blame] | 28 | } |
| 29 | // CTRUSE: ![[SC1]] = metadata !{metadata !"branch_weights", i32 100, i32 2} |
| 30 | |
| 31 | // DTRGEN-LABEL: define {{.*}} @_ZN6SimpleD2Ev( |
| 32 | // DTRUSE-LABEL: define {{.*}} @_ZN6SimpleD2Ev( |
| 33 | // DTRGEN: store {{.*}} @[[SDC:__llvm_pgo_ctr[0-9]*]], i64 0, i64 0 |
| 34 | ~Simple() { |
| 35 | // DTRGEN: store {{.*}} @[[SDC]], i64 0, i64 1 |
| 36 | // DTRUSE: br {{.*}} !prof ![[SD1:[0-9]+]] |
| 37 | if (Member) {} |
| 38 | // DTRGEN-NOT: store {{.*}} @[[SDC]], |
| 39 | // DTRUSE-NOT: br {{.*}} !prof ![0-9]+ |
Justin Bogner | 49e453f | 2014-01-23 04:41:06 +0000 | [diff] [blame] | 40 | // DTRUSE: ret |
Justin Bogner | 81c22c2 | 2014-01-23 02:54:27 +0000 | [diff] [blame] | 41 | } |
| 42 | // DTRUSE: ![[SD1]] = metadata !{metadata !"branch_weights", i32 100, i32 2} |
| 43 | |
| 44 | // MTHGEN-LABEL: define {{.*}} @_ZN6Simple6methodEv( |
| 45 | // MTHUSE-LABEL: define {{.*}} @_ZN6Simple6methodEv( |
| 46 | // MTHGEN: store {{.*}} @[[SMC:__llvm_pgo_ctr[0-9]*]], i64 0, i64 0 |
| 47 | void method() { |
| 48 | // MTHGEN: store {{.*}} @[[SMC]], i64 0, i64 1 |
| 49 | // MTHUSE: br {{.*}} !prof ![[SM1:[0-9]+]] |
| 50 | if (Member) {} |
| 51 | // MTHGEN-NOT: store {{.*}} @[[SMC]], |
| 52 | // MTHUSE-NOT: br {{.*}} !prof ![0-9]+ |
Justin Bogner | 49e453f | 2014-01-23 04:41:06 +0000 | [diff] [blame] | 53 | // MTHUSE: ret |
Justin Bogner | 81c22c2 | 2014-01-23 02:54:27 +0000 | [diff] [blame] | 54 | } |
| 55 | // MTHUSE: ![[SM1]] = metadata !{metadata !"branch_weights", i32 100, i32 2} |
| 56 | }; |
| 57 | |
| 58 | // WRPGEN-LABEL: define {{.*}} @_Z14simple_wrapperv( |
| 59 | // WRPUSE-LABEL: define {{.*}} @_Z14simple_wrapperv( |
| 60 | // WRPGEN: store {{.*}} @[[SWC:__llvm_pgo_ctr[0-9]*]], i64 0, i64 0 |
| 61 | void simple_wrapper() { |
| 62 | // WRPGEN: store {{.*}} @[[SWC]], i64 0, i64 1 |
| 63 | // WRPUSE: br {{.*}} !prof ![[SW1:[0-9]+]] |
| 64 | for (int I = 0; I < 100; ++I) { |
| 65 | Simple S(I); |
| 66 | S.method(); |
| 67 | } |
| 68 | // WRPGEN-NOT: store {{.*}} @[[SWC]], |
| 69 | // WRPUSE-NOT: br {{.*}} !prof ![0-9]+ |
Justin Bogner | 49e453f | 2014-01-23 04:41:06 +0000 | [diff] [blame] | 70 | // WRPUSE: ret |
Justin Bogner | 81c22c2 | 2014-01-23 02:54:27 +0000 | [diff] [blame] | 71 | } |
| 72 | // WRPUSE: ![[SW1]] = metadata !{metadata !"branch_weights", i32 100, i32 2} |
| 73 | |
| 74 | int main(int argc, const char *argv[]) { |
| 75 | simple_wrapper(); |
| 76 | return 0; |
| 77 | } |