• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 void @__kmpc_for_static_init_4(
23 // CHECK: call i32 @__kmpc_cancel(
24 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
25 // CHECK: call void @__kmpc_for_static_fini(
26 // CHECK: call void @__kmpc_barrier(%ident_t*
27 #pragma omp sections
28 {
29 #pragma omp cancel sections
30 #pragma omp section
31   {
32 #pragma omp cancel sections
33   }
34 }
35 // CHECK: call void @__kmpc_for_static_init_4(
36 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%ident_t* {{[^,]+}}, i32 [[GTID]], i32 3)
37 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
38 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
39 // CHECK: [[EXIT]]
40 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
41 // CHECK: br label
42 // CHECK: [[CONTINUE]]
43 // CHECK: br label
44 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%ident_t* {{[^,]+}}, i32 [[GTID]], i32 3)
45 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
46 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
47 // CHECK: [[EXIT]]
48 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
49 // CHECK: br label
50 // CHECK: [[CONTINUE]]
51 // CHECK: br label
52 // CHECK: call void @__kmpc_for_static_fini(
53 #pragma omp for
54 for (int i = 0; i < argc; ++i) {
55 #pragma omp cancel for if(cancel: flag)
56 }
57 // CHECK: call void @__kmpc_for_static_init_4(
58 // CHECK: [[FLAG:%.+]] = load float, float* @{{.+}},
59 // CHECK: [[BOOL:%.+]] = fcmp une float [[FLAG]], 0.000000e+00
60 // CHECK: br i1 [[BOOL]], label %[[THEN:[^,]+]], label %[[ELSE:[^,]+]]
61 // CHECK: [[THEN]]
62 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%ident_t* {{[^,]+}}, i32 [[GTID]], i32 2)
63 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
64 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
65 // CHECK: [[EXIT]]
66 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
67 // CHECK: br label
68 // CHECK: [[CONTINUE]]
69 // CHECK: br label
70 // CHECK: [[ELSE]]
71 // CHECK: br label
72 // CHECK: call void @__kmpc_for_static_fini(
73 // CHECK: call void @__kmpc_barrier(%ident_t*
74 #pragma omp task
75 {
76 #pragma omp cancel taskgroup
77 }
78 // CHECK: call i8* @__kmpc_omp_task_alloc(
79 // CHECK: call i32 @__kmpc_omp_task(
80 #pragma omp parallel sections
81 {
82 #pragma omp cancel sections
83 }
84 // CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
85 #pragma omp parallel sections
86 {
87 #pragma omp cancel sections
88 #pragma omp section
89   {
90 #pragma omp cancel sections
91   }
92 }
93 // CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
94 #pragma omp parallel for
95 for (int i = 0; i < argc; ++i) {
96 #pragma omp cancel for
97 }
98 // CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
99   return argc;
100 }
101 
102 // CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}},
103 // CHECK: [[FLAG:%.+]] = load float, float* @{{.+}},
104 // CHECK: [[BOOL:%.+]] = fcmp une float [[FLAG]], 0.000000e+00
105 // CHECK: br i1 [[BOOL]], label %[[THEN:[^,]+]], label %[[ELSE:[^,]+]]
106 // CHECK: [[THEN]]
107 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%ident_t* {{[^,]+}}, i32 {{[^,]+}}, i32 1)
108 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
109 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
110 // CHECK: [[EXIT]]
111 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
112 // CHECK: br label %[[RETURN:.+]]
113 // CHECK: [[ELSE]]
114 // CHECK: br label
115 // CHECK: [[RETURN]]
116 // CHECK: ret void
117 
118 // CHECK: define internal i32 @{{[^(]+}}(i32
119 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%ident_t* {{[^,]+}}, i32 {{[^,]+}}, i32 4)
120 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
121 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
122 // CHECK: [[EXIT]]
123 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
124 // CHECK: br label %[[RETURN:.+]]
125 // CHECK: [[RETURN]]
126 // CHECK: ret i32 0
127 
128 // CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}})
129 // CHECK: call void @__kmpc_for_static_init_4(
130 // CHECK: call i32 @__kmpc_cancel(
131 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
132 // CHECK: call void @__kmpc_for_static_fini(
133 // CHECK: ret void
134 
135 // CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}})
136 // CHECK: call void @__kmpc_for_static_init_4(
137 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%ident_t* {{[^,]+}}, i32 [[GTID:%.+]], i32 3)
138 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
139 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
140 // CHECK: [[EXIT]]
141 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
142 // CHECK: br label
143 // CHECK: [[CONTINUE]]
144 // CHECK: br label
145 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%ident_t* {{[^,]+}}, i32 [[GTID]], i32 3)
146 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
147 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
148 // CHECK: [[EXIT]]
149 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
150 // CHECK: br label
151 // CHECK: [[CONTINUE]]
152 // CHECK: br label
153 // CHECK: call void @__kmpc_for_static_fini(
154 // CHECK: ret void
155 
156 // CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}},
157 // CHECK: call void @__kmpc_for_static_init_4(
158 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%ident_t* {{[^,]+}}, i32 [[GTID:%.+]], i32 2)
159 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
160 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
161 // CHECK: [[EXIT]]
162 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
163 // CHECK: br label
164 // CHECK: [[CONTINUE]]
165 // CHECK: br label
166 // CHECK: call void @__kmpc_for_static_fini(
167 // CHECK: ret void
168 
169 #endif
170