1 // RUN: %clang_cc1 -verify -fopenmp -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck %s
4 // expected-no-diagnostics
5 // REQUIRES: x86-registered-target
6 #ifndef HEADER
7 #define HEADER
8
9 float flag;
main(int argc,char ** argv)10 int main (int argc, char **argv) {
11 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(
12 #pragma omp parallel
13 {
14 #pragma omp cancel parallel if(flag)
15 argv[0][0] = argc;
16 }
17 // CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
18 #pragma omp sections
19 {
20 #pragma omp cancel sections
21 }
22 // CHECK: call i32 @__kmpc_single(
23 // CHECK-NOT: @__kmpc_cancel
24 // CHECK: call void @__kmpc_end_single(
25 // CHECK: call void @__kmpc_barrier(%ident_t*
26 #pragma omp sections
27 {
28 #pragma omp cancel sections
29 #pragma omp section
30 {
31 #pragma omp cancel sections
32 }
33 }
34 // CHECK: call void @__kmpc_for_static_init_4(
35 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%ident_t* {{[^,]+}}, i32 [[GTID]], i32 3)
36 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
37 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
38 // CHECK: [[EXIT]]
39 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
40 // CHECK: br label
41 // CHECK: [[CONTINUE]]
42 // CHECK: br label
43 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%ident_t* {{[^,]+}}, i32 [[GTID]], i32 3)
44 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
45 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
46 // CHECK: [[EXIT]]
47 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
48 // CHECK: br label
49 // CHECK: [[CONTINUE]]
50 // CHECK: br label
51 // CHECK: call void @__kmpc_for_static_fini(
52 #pragma omp for
53 for (int i = 0; i < argc; ++i) {
54 #pragma omp cancel for if(cancel: flag)
55 }
56 // CHECK: call void @__kmpc_for_static_init_4(
57 // CHECK: [[FLAG:%.+]] = load float, float* @{{.+}},
58 // CHECK: [[BOOL:%.+]] = fcmp une float [[FLAG]], 0.000000e+00
59 // CHECK: br i1 [[BOOL]], label %[[THEN:[^,]+]], label %[[ELSE:[^,]+]]
60 // CHECK: [[THEN]]
61 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%ident_t* {{[^,]+}}, i32 [[GTID]], i32 2)
62 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
63 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
64 // CHECK: [[EXIT]]
65 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
66 // CHECK: br label
67 // CHECK: [[CONTINUE]]
68 // CHECK: br label
69 // CHECK: [[ELSE]]
70 // CHECK: br label
71 // CHECK: call void @__kmpc_for_static_fini(
72 // CHECK: call void @__kmpc_barrier(%ident_t*
73 #pragma omp task
74 {
75 #pragma omp cancel taskgroup
76 }
77 // CHECK: call i8* @__kmpc_omp_task_alloc(
78 // CHECK: call i32 @__kmpc_omp_task(
79 #pragma omp parallel sections
80 {
81 #pragma omp cancel sections
82 }
83 // CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
84 #pragma omp parallel sections
85 {
86 #pragma omp cancel sections
87 #pragma omp section
88 {
89 #pragma omp cancel sections
90 }
91 }
92 // CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
93 #pragma omp parallel for
94 for (int i = 0; i < argc; ++i) {
95 #pragma omp cancel for
96 }
97 // CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
98 return argc;
99 }
100
101 // CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}},
102 // CHECK: [[FLAG:%.+]] = load float, float* @{{.+}},
103 // CHECK: [[BOOL:%.+]] = fcmp une float [[FLAG]], 0.000000e+00
104 // CHECK: br i1 [[BOOL]], label %[[THEN:[^,]+]], label %[[ELSE:[^,]+]]
105 // CHECK: [[THEN]]
106 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%ident_t* {{[^,]+}}, i32 {{[^,]+}}, i32 1)
107 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
108 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
109 // CHECK: [[EXIT]]
110 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
111 // CHECK: br label %[[RETURN:.+]]
112 // CHECK: [[ELSE]]
113 // CHECK: br label
114 // CHECK: [[RETURN]]
115 // CHECK: ret void
116
117 // CHECK: define internal i32 @{{[^(]+}}(i32
118 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%ident_t* {{[^,]+}}, i32 {{[^,]+}}, i32 4)
119 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
120 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
121 // CHECK: [[EXIT]]
122 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
123 // CHECK: br label %[[RETURN:.+]]
124 // CHECK: [[RETURN]]
125 // CHECK: ret i32 0
126
127 // CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}})
128 // CHECK: call i32 @__kmpc_single(
129 // CHECK-NOT: @__kmpc_cancel
130 // CHECK: call void @__kmpc_end_single(
131 // CHECK: ret void
132
133 // CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}})
134 // CHECK: call void @__kmpc_for_static_init_4(
135 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%ident_t* {{[^,]+}}, i32 [[GTID:%.+]], i32 3)
136 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
137 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
138 // CHECK: [[EXIT]]
139 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
140 // CHECK: br label
141 // CHECK: [[CONTINUE]]
142 // CHECK: br label
143 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%ident_t* {{[^,]+}}, i32 [[GTID]], i32 3)
144 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
145 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
146 // CHECK: [[EXIT]]
147 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
148 // CHECK: br label
149 // CHECK: [[CONTINUE]]
150 // CHECK: br label
151 // CHECK: call void @__kmpc_for_static_fini(
152 // CHECK: ret void
153
154 // CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}},
155 // CHECK: call void @__kmpc_for_static_init_4(
156 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%ident_t* {{[^,]+}}, i32 [[GTID:%.+]], i32 2)
157 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
158 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
159 // CHECK: [[EXIT]]
160 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
161 // CHECK: br label
162 // CHECK: [[CONTINUE]]
163 // CHECK: br label
164 // CHECK: call void @__kmpc_for_static_fini(
165 // CHECK: ret void
166
167 #endif
168