| 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-instrument=clang > %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 |
|
| 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-instrument-use=clang -fprofile-instrument-use-path=%t.profdata > %tuse |
| 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 |
|
| 13 |
// The linkage can be target dependent, so accept all linkage here, |
| 14 |
// the linkage tests for different target are in llvm/test/Instrumentation/InstrProfiling/profiling.ll |
| 15 |
// T0GEN: @[[T0C:__profc__Z4loopILj0EEvv]] = {{.*}} global [2 x i64] zeroinitializer |
| 16 |
// T100GEN: @[[T100C:__profc__Z4loopILj100EEvv]] = {{.*}} global [2 x i64] zeroinitializer |
| 17 |
|
| 18 |
// T0GEN-LABEL: define linkonce_odr {{.*}}void @_Z4loopILj0EEvv() |
| 19 |
// T0USE-LABEL: define linkonce_odr {{.*}}void @_Z4loopILj0EEvv() |
| 20 |
// T100GEN-LABEL: define linkonce_odr {{.*}}void @_Z4loopILj100EEvv() |
| 21 |
// T100USE-LABEL: define linkonce_odr {{.*}}void @_Z4loopILj100EEvv() |
| 22 |
template <unsigned N> void loop() { |
| 23 |
// ALL-NOT: ret |
| 24 |
// T0GEN: store {{.*}} @[[T0C]] |
| 25 |
// T100GEN: store {{.*}} @[[T100C]] |
| 26 |
|
| 27 |
// ALL-NOT: ret |
| 28 |
// T0GEN: store {{.*}} @[[T0C]], i32 0, i32 1 |
| 29 |
// T0USE: br {{.*}} !prof ![[T01:[0-9]+]] |
| 30 |
// T100GEN: store {{.*}} @[[T100C]], i32 0, i32 1 |
| 31 |
// T100USE: br {{.*}} !prof ![[T1001:[0-9]+]] |
| 32 |
for (unsigned I = 0; I < N; ++I) {} |
| 33 |
|
| 34 |
// ALL: ret |
| 35 |
} |
| 36 |
|
| 37 |
// T0USE-DAG: ![[T01]] = !{!"branch_weights", i32 1, i32 2} |
| 38 |
// T100USE-DAG: ![[T1001]] = !{!"branch_weights", i32 101, i32 2} |
| 39 |
|
| 40 |
int main(int argc, const char *argv[]) { |
| 41 |
loop<0>(); |
| 42 |
loop<100>(); |
| 43 |
return 0; |
| 44 |
} |