diff options
author | dim <dim@FreeBSD.org> | 2014-11-24 09:15:30 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-11-24 09:15:30 +0000 |
commit | 173a4f43a911175643bda81ee675e8d9269056ea (patch) | |
tree | 47df2c12b57214af6c31e47404b005675b8b7ffc /test/Profile/cxx-lambda.cpp | |
parent | 88f7a7d5251a2d813460274c92decc143a11569b (diff) | |
download | FreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.zip FreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.tar.gz |
Vendor import of clang RELEASE_350/final tag r216957 (effectively, 3.5.0 release):
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_350/final@216957
Diffstat (limited to 'test/Profile/cxx-lambda.cpp')
-rw-r--r-- | test/Profile/cxx-lambda.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/Profile/cxx-lambda.cpp b/test/Profile/cxx-lambda.cpp new file mode 100644 index 0000000..6c37a86 --- /dev/null +++ b/test/Profile/cxx-lambda.cpp @@ -0,0 +1,58 @@ +// Tests for instrumentation of C++11 lambdas + +// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-generate > %tgen +// RUN: FileCheck --input-file=%tgen -check-prefix=PGOGEN %s +// RUN: FileCheck --input-file=%tgen -check-prefix=LMBGEN %s + +// RUN: llvm-profdata merge %S/Inputs/cxx-lambda.proftext -o %t.profdata +// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse +// RUN: FileCheck --input-file=%tuse -check-prefix=PGOUSE %s +// RUN: FileCheck --input-file=%tuse -check-prefix=LMBUSE %s + +// PGOGEN: @[[LWC:__llvm_profile_counters__Z7lambdasv]] = hidden global [4 x i64] zeroinitializer +// PGOGEN: @[[MAC:__llvm_profile_counters_main]] = hidden global [1 x i64] zeroinitializer +// LMBGEN: @[[LFC:"__llvm_profile_counters__ZZ7lambdasvENK3\$_0clEi"]] = internal global [3 x i64] zeroinitializer + +// PGOGEN-LABEL: define void @_Z7lambdasv() +// PGOUSE-LABEL: define void @_Z7lambdasv() +// PGOGEN: store {{.*}} @[[LWC]], i64 0, i64 0 +void lambdas() { + int i = 1; + + // LMBGEN-LABEL: define internal{{( zeroext)?}} i1 @"_ZZ7lambdasvENK3$_0clEi"( + // LMBUSE-LABEL: define internal{{( zeroext)?}} i1 @"_ZZ7lambdasvENK3$_0clEi"( + // 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) {} +} + +// PGOUSE-DAG: ![[LW1]] = metadata !{metadata !"branch_weights", i32 2, i32 1} +// PGOUSE-DAG: ![[LW2]] = metadata !{metadata !"branch_weights", i32 11, i32 2} +// PGOUSE-DAG: ![[LW3]] = metadata !{metadata !"branch_weights", i32 2, i32 1} + +// LMBUSE-DAG: ![[LF1]] = metadata !{metadata !"branch_weights", i32 10, i32 2} +// LMBUSE-DAG: ![[LF2]] = metadata !{metadata !"branch_weights", i32 10, i32 2} + +int main(int argc, const char *argv[]) { + lambdas(); + return 0; +} |