Home | History | Annotate | Download | only in Profile
      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-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 // T0GEN: @[[T0C:__profc__Z4loopILj0EEvv]] = linkonce_odr hidden global [2 x i64] zeroinitializer
     14 // T100GEN: @[[T100C:__profc__Z4loopILj100EEvv]] = linkonce_odr hidden global [2 x i64] zeroinitializer
     15 
     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()
     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 
     35 // T0USE-DAG: ![[T01]] = !{!"branch_weights", i32 1, i32 2}
     36 // T100USE-DAG: ![[T1001]] = !{!"branch_weights", i32 101, i32 2}
     37 
     38 int main(int argc, const char *argv[]) {
     39   loop<0>();
     40   loop<100>();
     41   return 0;
     42 }
     43