1 | // RUN: %clang_cc1 -verify -fopenmp -x c++ -emit-llvm -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -o - %s | FileCheck %s |
2 | // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown -emit-pch -o %t %s |
3 | // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-llvm -o - | FileCheck %s |
4 | |
5 | // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -emit-llvm -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -o - %s | FileCheck --check-prefix SIMD-ONLY0 %s |
6 | // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown -emit-pch -o %t %s |
7 | // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s |
8 | // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} |
9 | // expected-no-diagnostics |
10 | #ifndef HEADER |
11 | #define HEADER |
12 | // CHECK-LABEL: foo |
13 | void foo() {}; |
14 | // CHECK-LABEL: bar |
15 | void bar() {}; |
16 | |
17 | template <class T> |
18 | T tmain() { |
19 | #pragma omp parallel sections |
20 | { |
21 | foo(); |
22 | } |
23 | return T(); |
24 | } |
25 | |
26 | // CHECK-LABEL: @main |
27 | int main() { |
28 | // CHECK: call void (%{{.+}}*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OMP_PARALLEL_FUNC:@.+]] to void (i32*, i32*, ...)*)) |
29 | // CHECK-LABEL: } |
30 | // CHECK: define internal void [[OMP_PARALLEL_FUNC]](i32* noalias [[GTID_PARAM_ADDR:%.+]], i32* noalias %{{.+}}) |
31 | // CHECK: store i32* [[GTID_PARAM_ADDR]], i32** [[GTID_REF_ADDR:%.+]], |
32 | #pragma omp parallel sections |
33 | { |
34 | // CHECK: store i32 0, i32* [[LB_PTR:%.+]], |
35 | // CHECK: store i32 1, i32* [[UB_PTR:%.+]], |
36 | // CHECK: call void @__kmpc_for_static_init_4(%{{.+}}* @{{.+}}, i32 [[GTID:%.+]], i32 34, i32* [[IS_LAST_PTR:%.+]], i32* [[LB_PTR]], i32* [[UB_PTR]], i32* [[STRIDE_PTR:%.+]], i32 1, i32 1) |
37 | // <<UB = min(UB, GlobalUB);>> |
38 | // CHECK: [[UB:%.+]] = load i32, i32* [[UB_PTR]] |
39 | // CHECK: [[CMP:%.+]] = icmp slt i32 [[UB]], 1 |
40 | // CHECK: [[MIN_UB_GLOBALUB:%.+]] = select i1 [[CMP]], i32 [[UB]], i32 1 |
41 | // CHECK: store i32 [[MIN_UB_GLOBALUB]], i32* [[UB_PTR]] |
42 | // <<IV = LB;>> |
43 | // CHECK: [[LB:%.+]] = load i32, i32* [[LB_PTR]] |
44 | // CHECK: store i32 [[LB]], i32* [[IV_PTR:%.+]] |
45 | // CHECK: br label %[[INNER_FOR_COND:.+]] |
46 | // CHECK: [[INNER_FOR_COND]] |
47 | // <<IV <= UB?>> |
48 | // CHECK: [[IV:%.+]] = load i32, i32* [[IV_PTR]] |
49 | // CHECK: [[UB:%.+]] = load i32, i32* [[UB_PTR]] |
50 | // CHECK: [[CMP:%.+]] = icmp sle i32 [[IV]], [[UB]] |
51 | // CHECK: br i1 [[CMP]], label %[[INNER_LOOP_BODY:.+]], label %[[INNER_LOOP_END:.+]] |
52 | // CHECK: [[INNER_LOOP_BODY]] |
53 | // <<TRUE>> - > <BODY> |
54 | // CHECK: [[IV:%.+]] = load i32, i32* [[IV_PTR]] |
55 | // CHECK: switch i32 [[IV]], label %[[SECTIONS_EXIT:.+]] [ |
56 | // CHECK-NEXT: i32 0, label %[[SECTIONS_CASE0:.+]] |
57 | // CHECK-NEXT: i32 1, label %[[SECTIONS_CASE1:.+]] |
58 | #pragma omp section |
59 | // CHECK: [[SECTIONS_CASE0]] |
60 | // CHECK-NEXT: invoke void @{{.*}}foo{{.*}}() |
61 | // CHECK: br label %[[SECTIONS_EXIT]] |
62 | foo(); |
63 | #pragma omp section |
64 | // CHECK: [[SECTIONS_CASE1]] |
65 | // CHECK-NEXT: invoke void @{{.*}}bar{{.*}}() |
66 | // CHECK: br label %[[SECTIONS_EXIT]] |
67 | bar(); |
68 | // CHECK: [[SECTIONS_EXIT]] |
69 | // <<++IV;>> |
70 | // CHECK: [[IV:%.+]] = load i32, i32* [[IV_PTR]] |
71 | // CHECK-NEXT: [[INC:%.+]] = add nsw i32 [[IV]], 1 |
72 | // CHECK-NEXT: store i32 [[INC]], i32* [[IV_PTR]] |
73 | // CHECK-NEXT: br label %[[INNER_FOR_COND]] |
74 | // CHECK: [[INNER_LOOP_END]] |
75 | } |
76 | // CHECK: call void @__kmpc_for_static_fini(%{{.+}}* @{{.+}}, i32 [[GTID]]) |
77 | return tmain<int>(); |
78 | } |
79 | |
80 | // CHECK-LABEL: tmain |
81 | // CHECK: call void {{.*}} @__kmpc_fork_call( |
82 | // CHECK-NOT: __kmpc_global_thread_num |
83 | // CHECK: call void @__kmpc_for_static_init_4( |
84 | // CHECK: invoke void @{{.*}}foo{{.*}}() |
85 | // CHECK-NEXT: unwind label %[[TERM_LPAD:.+]] |
86 | // CHECK: call void @__kmpc_for_static_fini( |
87 | // CHECK-NEXT: ret |
88 | // CHECK: [[TERM_LPAD]] |
89 | // CHECK: call void @__clang_call_terminate(i8* |
90 | // CHECK-NEXT: unreachable |
91 | |
92 | #endif |
93 | |