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 | 534f14a | 2014-04-17 22:49:06 +0000 | [diff] [blame] | 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 |
Justin Bogner | 81c22c2 | 2014-01-23 02:54:27 +0000 | [diff] [blame] | 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 |
| 15 | |
| 16 | class Simple { |
| 17 | int Member; |
| 18 | public: |
| 19 | // CTRGEN-LABEL: define {{.*}} @_ZN6SimpleC2Ei( |
| 20 | // CTRUSE-LABEL: define {{.*}} @_ZN6SimpleC2Ei( |
Xinliang David Li | ddbdb1e | 2015-12-15 00:33:12 +0000 | [diff] [blame] | 21 | // CTRGEN: store {{.*}} @[[SCC:__profc__ZN6SimpleC2Ei]], i64 0, i64 0 |
Justin Bogner | 81c22c2 | 2014-01-23 02:54:27 +0000 | [diff] [blame] | 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]+ |
Justin Bogner | 49e453f | 2014-01-23 04:41:06 +0000 | [diff] [blame] | 28 | // CTRUSE: ret |
Justin Bogner | 81c22c2 | 2014-01-23 02:54:27 +0000 | [diff] [blame] | 29 | } |
Duncan P. N. Exon Smith | b3a6669 | 2014-12-15 19:10:08 +0000 | [diff] [blame] | 30 | // CTRUSE: ![[SC1]] = !{!"branch_weights", i32 100, i32 2} |
Justin Bogner | 81c22c2 | 2014-01-23 02:54:27 +0000 | [diff] [blame] | 31 | |
| 32 | // DTRGEN-LABEL: define {{.*}} @_ZN6SimpleD2Ev( |
| 33 | // DTRUSE-LABEL: define {{.*}} @_ZN6SimpleD2Ev( |
Xinliang David Li | ddbdb1e | 2015-12-15 00:33:12 +0000 | [diff] [blame] | 34 | // DTRGEN: store {{.*}} @[[SDC:__profc__ZN6SimpleD2Ev]], i64 0, i64 0 |
Justin Bogner | 81c22c2 | 2014-01-23 02:54:27 +0000 | [diff] [blame] | 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]+ |
Justin Bogner | 49e453f | 2014-01-23 04:41:06 +0000 | [diff] [blame] | 41 | // DTRUSE: ret |
Justin Bogner | 81c22c2 | 2014-01-23 02:54:27 +0000 | [diff] [blame] | 42 | } |
Duncan P. N. Exon Smith | b3a6669 | 2014-12-15 19:10:08 +0000 | [diff] [blame] | 43 | // DTRUSE: ![[SD1]] = !{!"branch_weights", i32 100, i32 2} |
Justin Bogner | 81c22c2 | 2014-01-23 02:54:27 +0000 | [diff] [blame] | 44 | |
| 45 | // MTHGEN-LABEL: define {{.*}} @_ZN6Simple6methodEv( |
| 46 | // MTHUSE-LABEL: define {{.*}} @_ZN6Simple6methodEv( |
Xinliang David Li | ddbdb1e | 2015-12-15 00:33:12 +0000 | [diff] [blame] | 47 | // MTHGEN: store {{.*}} @[[SMC:__profc__ZN6Simple6methodEv]], i64 0, i64 0 |
Justin Bogner | 81c22c2 | 2014-01-23 02:54:27 +0000 | [diff] [blame] | 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]+ |
Justin Bogner | 49e453f | 2014-01-23 04:41:06 +0000 | [diff] [blame] | 54 | // MTHUSE: ret |
Justin Bogner | 81c22c2 | 2014-01-23 02:54:27 +0000 | [diff] [blame] | 55 | } |
Duncan P. N. Exon Smith | b3a6669 | 2014-12-15 19:10:08 +0000 | [diff] [blame] | 56 | // MTHUSE: ![[SM1]] = !{!"branch_weights", i32 100, i32 2} |
Justin Bogner | 81c22c2 | 2014-01-23 02:54:27 +0000 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | // WRPGEN-LABEL: define {{.*}} @_Z14simple_wrapperv( |
| 60 | // WRPUSE-LABEL: define {{.*}} @_Z14simple_wrapperv( |
Xinliang David Li | ddbdb1e | 2015-12-15 00:33:12 +0000 | [diff] [blame] | 61 | // WRPGEN: store {{.*}} @[[SWC:__profc__Z14simple_wrapperv]], i64 0, i64 0 |
Justin Bogner | 81c22c2 | 2014-01-23 02:54:27 +0000 | [diff] [blame] | 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(); |
| 68 | } |
| 69 | // WRPGEN-NOT: store {{.*}} @[[SWC]], |
| 70 | // WRPUSE-NOT: br {{.*}} !prof ![0-9]+ |
Justin Bogner | 49e453f | 2014-01-23 04:41:06 +0000 | [diff] [blame] | 71 | // WRPUSE: ret |
Justin Bogner | 81c22c2 | 2014-01-23 02:54:27 +0000 | [diff] [blame] | 72 | } |
Duncan P. N. Exon Smith | b3a6669 | 2014-12-15 19:10:08 +0000 | [diff] [blame] | 73 | // WRPUSE: ![[SW1]] = !{!"branch_weights", i32 101, i32 2} |
Justin Bogner | 81c22c2 | 2014-01-23 02:54:27 +0000 | [diff] [blame] | 74 | |
| 75 | int main(int argc, const char *argv[]) { |
| 76 | simple_wrapper(); |
| 77 | return 0; |
| 78 | } |