1 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-pc-windows-msvc18.0.0 -std=c++11 -fms-compatibility-version=18 -fms-extensions -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
2
3 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-pc-windows-msvc18.0.0 -std=c++11 -fms-compatibility-version=18 -fms-extensions -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s
4
5 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
6 // expected-no-diagnostics
7
8 void foo();
9 void bar();
10
11 struct Test {
mainTest12 static void main() {
13 int failed = 0;
14 int j = 2;
15
16 #pragma omp parallel
17 {
18 int local_j = 3;
19 #pragma omp single copyprivate(local_j)
20 {
21 local_j = 4;
22 }
23
24 // Assure reports a data race, but value written to "j"
25 // should always be the same.
26 j = local_j;
27 }
28
29 }
30 };
31
32 // CHECK-LABEL: @main
main()33 int main() {
34 // CHECK: call void @{{.+}}main
35 Test::main();
36 // CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* {{.*}}@1, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED:@.+]] to void (i32*, i32*, ...)*))
37 #pragma omp parallel
38 {
39 try {
40 foo();
41 } catch (int t) {
42 #pragma omp critical
43 {
44 bar();
45 };
46 }
47 };
48 // CHECK: ret i32 0
49 return 0;
50 }
51
52 // CHECK: define internal void [[OUTLINED]](
53 // CHECK: invoke void @{{.+}}foo
54 // CHECK: [[CATCHSWITCH:%.+]] = catchswitch within none
55 // CHECK: [[CATCHPAD:%.+]] = catchpad within [[CATCHSWITCH]]
56 // CHECK: call void @__kmpc_critical(%struct.ident_t* {{.*}}@1, i32 [[GID:%.+]],
57 // CHECK: invoke void @{{.+}}bar
58 // CHECK: call void @__kmpc_end_critical(%struct.ident_t* {{.*}}@1, i32 [[GID]],
59 // CHECK: catchret from [[CATCHPAD]] to
60 // CHECK: cleanuppad within [[CATCHPAD]] []
61 // CHECK-NEXT: call void @__kmpc_end_critical(%struct.ident_t* {{.*}}@1, i32 [[GID]],
62 // CHECK-NEXT: cleanupret from {{.*}} unwind label %[[CATCHTERM:[^ ]+]]
63 // CHECK: cleanuppad within none []
64 // CHECK-NEXT: call void @"?terminate@@YAXXZ"() #{{[0-9]+}} [ "funclet"(token %{{.*}}) ]
65 // CHECK-NEXT: unreachable
66 // CHECK: [[CATCHTERM]]
67 // CHECK-NEXT: cleanuppad within [[CATCHPAD]] []
68 // CHECK-NEXT: call void @"?terminate@@YAXXZ"() #{{[0-9]+}} [ "funclet"(token %{{.*}}) ]
69 // CHECK-NEXT: unreachable
70