1 // Tests for instrumentation of C++11 range-for
3 // RUN: %clang_cc1 -no-opaque-pointers -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-rangefor.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument=clang > %tgen
4 // RUN: FileCheck --input-file=%tgen -check-prefix=CHECK -check-prefix=PGOGEN %s
6 // RUN: llvm-profdata merge %S/Inputs/cxx-rangefor.proftext -o %t.profdata
7 // RUN: %clang_cc1 -no-opaque-pointers -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-rangefor.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata > %tuse
8 // RUN: FileCheck --input-file=%tuse -check-prefix=CHECK -check-prefix=PGOUSE %s
10 // PGOGEN: @[[RFC:__profc__Z9range_forv]] = {{(private|internal)}} global [5 x i64] zeroinitializer
12 // CHECK-LABEL: define {{.*}}void @_Z9range_forv()
13 // PGOGEN: store {{.*}} @[[RFC]], i32 0, i32 0
15 int arr
[] = {1, 2, 3, 4, 5};
17 // PGOGEN: store {{.*}} @[[RFC]], i32 0, i32 1
18 // PGOUSE: br {{.*}} !prof ![[RF1:[0-9]+]]
20 // PGOGEN: store {{.*}} @[[RFC]], i32 0, i32 2
21 // PGOUSE: br {{.*}} !prof ![[RF2:[0-9]+]]
25 // PGOGEN: store {{.*}} @[[RFC]], i32 0, i32 3
26 // PGOUSE: br {{.*}} !prof ![[RF3:[0-9]+]]
31 // PGOGEN: store {{.*}} @[[RFC]], i32 0, i32 4
32 // PGOUSE: br {{.*}} !prof ![[RF4:[0-9]+]]
36 // PGOUSE-DAG: ![[RF1]] = !{!"branch_weights", i32 5, i32 1}
37 // PGOUSE-DAG: ![[RF2]] = !{!"branch_weights", i32 2, i32 4}
38 // PGOUSE-DAG: ![[RF3]] = !{!"branch_weights", i32 2, i32 3}
39 // PGOUSE-DAG: ![[RF4]] = !{!"branch_weights", i32 2, i32 1}
41 int main(int argc
, const char *argv
[]) {