[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / cancel_codegen_cleanup.cpp
blob720fbef8d4e2166130eb1192b85c6cfa02fdc17e
1 // RUN: %clang_cc1 -std=c++11 -fopenmp -fopenmp-version=45 -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck %s
3 // RUN: %clang_cc1 -std=c++11 -fopenmp-simd -fopenmp-version=45 -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck --check-prefix SIMD-ONLY0 %s
4 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
6 // RUN: %clang_cc1 -std=c++11 -fopenmp -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck %s
7 // RUN: %clang_cc1 -std=c++11 -fopenmp-simd -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck --check-prefix SIMD-ONLY0 %s
8 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
10 //CHECK: call i32 @__kmpc_cancel
11 //CHECK: br {{.*}}label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
12 //CHECK: [[EXIT]]:
13 //CHECK: store i32 [[EXIT_SLOT:[0-9]+]]
14 //CHECK: br label %[[CLEANUP:.+]]
15 //CHECK: [[CONTINUE]]:
16 //CHECK: store i32 [[CONT_SLOT:[0-9]+]],
17 //CHECK: br label %[[CLEANUP]]
18 //CHECK: [[CLEANUP]]:
19 //CHECK-NEXT: call void @_ZN3ObjD1Ev
20 //CHECK: switch i32{{.*}}, label %[[UNREACHABLE:.+]] [
21 //CHECK: i32 [[CONT_SLOT]], label %[[CLEANUPCONT:.+]]
22 //CHECK: i32 [[EXIT_SLOT]], label %[[CANCELEXIT:.+]]
23 //CHECK-NEXT: ]
24 //CHECK: [[CLEANUPCONT]]:
25 //CHECK: br label %[[CANCELCONT:.+]]
26 //CHECK: [[CANCELCONT]]:
27 //CHECK-NEXT: call void @__kmpc_barrier(
28 //CHECK-NEXT: ret void
29 //CHECK: [[UNREACHABLE]]:
30 //CHECK-NEXT: unreachable
31 //CHECK-NEXT: }
33 struct Obj {
34 int a; Obj(); Obj(const Obj& r) = delete; Obj &operator=(const Obj& r);
35 ~Obj();
38 void foo() {
39 int i,count = 0;
40 Obj obj;
42 #pragma omp parallel private(i) num_threads(1)
44 #pragma omp for reduction(+:count) lastprivate(obj)
45 for (i=0; i<1000; i++) {
46 if(i==100) {
47 obj.a = 100;
48 #pragma omp cancel for
50 count++;