2014-04-12 07:06:35 +08:00
|
|
|
// Tests for instrumentation of C++11 lambdas
|
|
|
|
|
2016-02-05 02:39:09 +08:00
|
|
|
// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument=clang > %tgen
|
2018-07-12 04:26:20 +08:00
|
|
|
// RUN: FileCheck -allow-deprecated-dag-overlap --input-file=%tgen -check-prefix=PGOGEN %s
|
|
|
|
// RUN: FileCheck -allow-deprecated-dag-overlap --input-file=%tgen -check-prefix=LMBGEN %s
|
2014-04-12 07:06:35 +08:00
|
|
|
|
2014-04-18 06:49:06 +08:00
|
|
|
// RUN: llvm-profdata merge %S/Inputs/cxx-lambda.proftext -o %t.profdata
|
2016-03-03 04:59:36 +08:00
|
|
|
// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata > %tuse
|
2018-07-12 04:26:20 +08:00
|
|
|
// RUN: FileCheck -allow-deprecated-dag-overlap --input-file=%tuse -check-prefix=PGOUSE %s
|
|
|
|
// RUN: FileCheck -allow-deprecated-dag-overlap --input-file=%tuse -check-prefix=LMBUSE %s
|
2014-04-12 07:06:35 +08:00
|
|
|
|
2019-02-11 04:17:07 +08:00
|
|
|
// PGOGEN: @[[LWC:__profc__Z7lambdasv]] = {{(private|internal)}} global [4 x i64] zeroinitializer
|
|
|
|
// PGOGEN: @[[MAC:__profc_main]] = {{(private|internal)}} global [1 x i64] zeroinitializer
|
|
|
|
// LMBGEN: @[[LFC:"__profc_cxx_lambda.cpp__ZZ7lambdasvENK3\$_0clEi"]] = {{(private|internal)}} global [3 x i64] zeroinitializer
|
2014-04-12 07:06:35 +08:00
|
|
|
|
2015-06-30 01:29:50 +08:00
|
|
|
// PGOGEN-LABEL: define {{.*}}void @_Z7lambdasv()
|
|
|
|
// PGOUSE-LABEL: define {{.*}}void @_Z7lambdasv()
|
2014-04-12 07:06:35 +08:00
|
|
|
// PGOGEN: store {{.*}} @[[LWC]], i64 0, i64 0
|
|
|
|
void lambdas() {
|
|
|
|
int i = 1;
|
|
|
|
|
2015-06-30 16:02:26 +08:00
|
|
|
// LMBGEN-LABEL: define internal{{( [0-9_a-z]*cc)?( zeroext)?}} i1 @"_ZZ7lambdasvENK3$_0clEi"(
|
|
|
|
// LMBUSE-LABEL: define internal{{( [0-9_a-z]*cc)?( zeroext)?}} i1 @"_ZZ7lambdasvENK3$_0clEi"(
|
2014-04-12 07:06:35 +08:00
|
|
|
// LMBGEN: store {{.*}} @[[LFC]], i64 0, i64 0
|
|
|
|
auto f = [&i](int k) {
|
|
|
|
// LMBGEN: store {{.*}} @[[LFC]], i64 0, i64 1
|
|
|
|
// LMBUSE: br {{.*}} !prof ![[LF1:[0-9]+]]
|
|
|
|
if (i > 0) {}
|
|
|
|
// LMBGEN: store {{.*}} @[[LFC]], i64 0, i64 2
|
|
|
|
// LMBUSE: br {{.*}} !prof ![[LF2:[0-9]+]]
|
|
|
|
return k && i;
|
|
|
|
};
|
|
|
|
|
|
|
|
// PGOGEN: store {{.*}} @[[LWC]], i64 0, i64 1
|
|
|
|
// PGOUSE: br {{.*}} !prof ![[LW1:[0-9]+]]
|
|
|
|
if (i) {}
|
|
|
|
|
|
|
|
// PGOGEN: store {{.*}} @[[LWC]], i64 0, i64 2
|
|
|
|
// PGOUSE: br {{.*}} !prof ![[LW2:[0-9]+]]
|
|
|
|
for (i = 0; i < 10; ++i)
|
|
|
|
f(9 - i);
|
|
|
|
|
|
|
|
// PGOGEN: store {{.*}} @[[LWC]], i64 0, i64 3
|
|
|
|
// PGOUSE: br {{.*}} !prof ![[LW3:[0-9]+]]
|
|
|
|
if (i) {}
|
|
|
|
}
|
|
|
|
|
2014-12-16 03:10:08 +08:00
|
|
|
// PGOUSE-DAG: ![[LW1]] = !{!"branch_weights", i32 2, i32 1}
|
|
|
|
// PGOUSE-DAG: ![[LW2]] = !{!"branch_weights", i32 11, i32 2}
|
|
|
|
// PGOUSE-DAG: ![[LW3]] = !{!"branch_weights", i32 2, i32 1}
|
2014-04-12 07:06:35 +08:00
|
|
|
|
2014-12-16 03:10:08 +08:00
|
|
|
// LMBUSE-DAG: ![[LF1]] = !{!"branch_weights", i32 10, i32 2}
|
|
|
|
// LMBUSE-DAG: ![[LF2]] = !{!"branch_weights", i32 10, i32 2}
|
2014-04-12 07:06:35 +08:00
|
|
|
|
|
|
|
int main(int argc, const char *argv[]) {
|
|
|
|
lambdas();
|
|
|
|
return 0;
|
|
|
|
}
|