Justin Bogner | b196629 | 2014-04-12 00:54:06 +0000 | [diff] [blame] | 1 | // Tests for instrumentation of templated code. Each instantiation of a template |
| 2 | // should be instrumented separately. |
| 3 | |
| 4 | // RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-generate > %tgen |
| 5 | // RUN: FileCheck --input-file=%tgen -check-prefix=T0GEN -check-prefix=ALL %s |
| 6 | // RUN: FileCheck --input-file=%tgen -check-prefix=T100GEN -check-prefix=ALL %s |
| 7 | |
Justin Bogner | 534f14a | 2014-04-17 22:49:06 +0000 | [diff] [blame] | 8 | // RUN: llvm-profdata merge %S/Inputs/cxx-templates.proftext -o %t.profdata |
| 9 | // RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse |
Justin Bogner | b196629 | 2014-04-12 00:54:06 +0000 | [diff] [blame] | 10 | // RUN: FileCheck --input-file=%tuse -check-prefix=T0USE -check-prefix=ALL %s |
| 11 | // RUN: FileCheck --input-file=%tuse -check-prefix=T100USE -check-prefix=ALL %s |
| 12 | |
Duncan P. N. Exon Smith | 9121220 | 2014-05-16 01:24:00 +0000 | [diff] [blame] | 13 | // T0GEN: @[[T0C:__llvm_profile_counters__Z4loopILj0EEvv]] = linkonce_odr hidden global [2 x i64] zeroinitializer |
| 14 | // T100GEN: @[[T100C:__llvm_profile_counters__Z4loopILj100EEvv]] = linkonce_odr hidden global [2 x i64] zeroinitializer |
Justin Bogner | b196629 | 2014-04-12 00:54:06 +0000 | [diff] [blame] | 15 | |
David Blaikie | ea3e51d | 2015-06-29 17:29:50 +0000 | [diff] [blame^] | 16 | // T0GEN-LABEL: define linkonce_odr {{.*}}void @_Z4loopILj0EEvv() |
| 17 | // T0USE-LABEL: define linkonce_odr {{.*}}void @_Z4loopILj0EEvv() |
| 18 | // T100GEN-LABEL: define linkonce_odr {{.*}}void @_Z4loopILj100EEvv() |
| 19 | // T100USE-LABEL: define linkonce_odr {{.*}}void @_Z4loopILj100EEvv() |
Justin Bogner | b196629 | 2014-04-12 00:54:06 +0000 | [diff] [blame] | 20 | template <unsigned N> void loop() { |
| 21 | // ALL-NOT: ret |
| 22 | // T0GEN: store {{.*}} @[[T0C]], i64 0, i64 0 |
| 23 | // T100GEN: store {{.*}} @[[T100C]], i64 0, i64 0 |
| 24 | |
| 25 | // ALL-NOT: ret |
| 26 | // T0GEN: store {{.*}} @[[T0C]], i64 0, i64 1 |
| 27 | // T0USE: br {{.*}} !prof ![[T01:[0-9]+]] |
| 28 | // T100GEN: store {{.*}} @[[T100C]], i64 0, i64 1 |
| 29 | // T100USE: br {{.*}} !prof ![[T1001:[0-9]+]] |
| 30 | for (unsigned I = 0; I < N; ++I) {} |
| 31 | |
| 32 | // ALL: ret |
| 33 | } |
| 34 | |
Duncan P. N. Exon Smith | b3a6669 | 2014-12-15 19:10:08 +0000 | [diff] [blame] | 35 | // T0USE-DAG: ![[T01]] = !{!"branch_weights", i32 1, i32 2} |
| 36 | // T100USE-DAG: ![[T1001]] = !{!"branch_weights", i32 101, i32 2} |
Justin Bogner | b196629 | 2014-04-12 00:54:06 +0000 | [diff] [blame] | 37 | |
| 38 | int main(int argc, const char *argv[]) { |
| 39 | loop<0>(); |
| 40 | loop<100>(); |
| 41 | return 0; |
| 42 | } |