Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / taskgroup_codegen.cpp
blob61105a6472e37eeadd1439ca7f185ec2ee8a0ea6
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _
2 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix=CHECK1
3 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
4 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK1
5 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=DEBUG1
7 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
8 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
9 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
10 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
12 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix=CHECK2
14 // expected-no-diagnostics
15 #ifndef HEADER
16 #define HEADER
18 void foo() { extern void mayThrow(); mayThrow(); }
20 int main() {
21 char a;
22 #pragma omp taskgroup
23 a = 2;
24 #pragma omp taskgroup
25 foo();
26 return a;
29 void parallel_taskgroup() {
30 #pragma omp parallel
31 #pragma omp taskgroup
32 foo();
34 #endif
49 // CHECK1-LABEL: define {{[^@]+}}@_Z3foov
50 // CHECK1-SAME: () #[[ATTR0:[0-9]+]] {
51 // CHECK1-NEXT: entry:
52 // CHECK1-NEXT: call void @_Z8mayThrowv()
53 // CHECK1-NEXT: ret void
56 // CHECK1-LABEL: define {{[^@]+}}@main
57 // CHECK1-SAME: () #[[ATTR2:[0-9]+]] personality ptr @__gxx_personality_v0 {
58 // CHECK1-NEXT: entry:
59 // CHECK1-NEXT: [[RETVAL:%.*]] = alloca i32, align 4
60 // CHECK1-NEXT: [[A:%.*]] = alloca i8, align 1
61 // CHECK1-NEXT: [[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB1:[0-9]+]])
62 // CHECK1-NEXT: store i32 0, ptr [[RETVAL]], align 4
63 // CHECK1-NEXT: call void @__kmpc_taskgroup(ptr @[[GLOB1]], i32 [[TMP0]])
64 // CHECK1-NEXT: store i8 2, ptr [[A]], align 1
65 // CHECK1-NEXT: call void @__kmpc_end_taskgroup(ptr @[[GLOB1]], i32 [[TMP0]])
66 // CHECK1-NEXT: call void @__kmpc_taskgroup(ptr @[[GLOB1]], i32 [[TMP0]])
67 // CHECK1-NEXT: invoke void @_Z3foov()
68 // CHECK1-NEXT: to label [[INVOKE_CONT:%.*]] unwind label [[TERMINATE_LPAD:%.*]]
69 // CHECK1: invoke.cont:
70 // CHECK1-NEXT: call void @__kmpc_end_taskgroup(ptr @[[GLOB1]], i32 [[TMP0]])
71 // CHECK1-NEXT: [[TMP1:%.*]] = load i8, ptr [[A]], align 1
72 // CHECK1-NEXT: [[CONV:%.*]] = sext i8 [[TMP1]] to i32
73 // CHECK1-NEXT: ret i32 [[CONV]]
74 // CHECK1: terminate.lpad:
75 // CHECK1-NEXT: [[TMP2:%.*]] = landingpad { ptr, i32 }
76 // CHECK1-NEXT: catch ptr null
77 // CHECK1-NEXT: [[TMP3:%.*]] = extractvalue { ptr, i32 } [[TMP2]], 0
78 // CHECK1-NEXT: call void @__clang_call_terminate(ptr [[TMP3]]) #[[ATTR8:[0-9]+]]
79 // CHECK1-NEXT: unreachable
82 // CHECK1-LABEL: define {{[^@]+}}@__clang_call_terminate
83 // CHECK1-SAME: (ptr noundef [[TMP0:%.*]]) #[[ATTR5:[0-9]+]] comdat {
84 // CHECK1-NEXT: [[TMP2:%.*]] = call ptr @__cxa_begin_catch(ptr [[TMP0]]) #[[ATTR3:[0-9]+]]
85 // CHECK1-NEXT: call void @_ZSt9terminatev() #[[ATTR8]]
86 // CHECK1-NEXT: unreachable
89 // CHECK1-LABEL: define {{[^@]+}}@_Z18parallel_taskgroupv
90 // CHECK1-SAME: () #[[ATTR6:[0-9]+]] {
91 // CHECK1-NEXT: entry:
92 // CHECK1-NEXT: call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB1]], i32 0, ptr @_Z18parallel_taskgroupv.omp_outlined)
93 // CHECK1-NEXT: ret void
96 // CHECK1-LABEL: define {{[^@]+}}@_Z18parallel_taskgroupv.omp_outlined
97 // CHECK1-SAME: (ptr noalias noundef [[DOTGLOBAL_TID_:%.*]], ptr noalias noundef [[DOTBOUND_TID_:%.*]]) #[[ATTR7:[0-9]+]] personality ptr @__gxx_personality_v0 {
98 // CHECK1-NEXT: entry:
99 // CHECK1-NEXT: [[DOTGLOBAL_TID__ADDR:%.*]] = alloca ptr, align 8
100 // CHECK1-NEXT: [[DOTBOUND_TID__ADDR:%.*]] = alloca ptr, align 8
101 // CHECK1-NEXT: store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
102 // CHECK1-NEXT: store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
103 // CHECK1-NEXT: [[TMP0:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
104 // CHECK1-NEXT: [[TMP1:%.*]] = load i32, ptr [[TMP0]], align 4
105 // CHECK1-NEXT: call void @__kmpc_taskgroup(ptr @[[GLOB1]], i32 [[TMP1]])
106 // CHECK1-NEXT: invoke void @_Z3foov()
107 // CHECK1-NEXT: to label [[INVOKE_CONT:%.*]] unwind label [[TERMINATE_LPAD:%.*]]
108 // CHECK1: invoke.cont:
109 // CHECK1-NEXT: call void @__kmpc_end_taskgroup(ptr @[[GLOB1]], i32 [[TMP1]])
110 // CHECK1-NEXT: ret void
111 // CHECK1: terminate.lpad:
112 // CHECK1-NEXT: [[TMP2:%.*]] = landingpad { ptr, i32 }
113 // CHECK1-NEXT: catch ptr null
114 // CHECK1-NEXT: [[TMP3:%.*]] = extractvalue { ptr, i32 } [[TMP2]], 0
115 // CHECK1-NEXT: call void @__clang_call_terminate(ptr [[TMP3]]) #[[ATTR8]]
116 // CHECK1-NEXT: unreachable
119 // DEBUG1-LABEL: define {{[^@]+}}@_Z3foov
120 // DEBUG1-SAME: () #[[ATTR0:[0-9]+]] !dbg [[DBG6:![0-9]+]] {
121 // DEBUG1-NEXT: entry:
122 // DEBUG1-NEXT: call void @_Z8mayThrowv(), !dbg [[DBG10:![0-9]+]]
123 // DEBUG1-NEXT: ret void, !dbg [[DBG11:![0-9]+]]
126 // DEBUG1-LABEL: define {{[^@]+}}@main
127 // DEBUG1-SAME: () #[[ATTR2:[0-9]+]] personality ptr @__gxx_personality_v0 !dbg [[DBG12:![0-9]+]] {
128 // DEBUG1-NEXT: entry:
129 // DEBUG1-NEXT: [[RETVAL:%.*]] = alloca i32, align 4
130 // DEBUG1-NEXT: [[A:%.*]] = alloca i8, align 1
131 // DEBUG1-NEXT: [[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB1:[0-9]+]])
132 // DEBUG1-NEXT: store i32 0, ptr [[RETVAL]], align 4
133 // DEBUG1-NEXT: call void @__kmpc_taskgroup(ptr @[[GLOB1]], i32 [[TMP0]]), !dbg [[DBG13:![0-9]+]]
134 // DEBUG1-NEXT: store i8 2, ptr [[A]], align 1, !dbg [[DBG14:![0-9]+]]
135 // DEBUG1-NEXT: call void @__kmpc_end_taskgroup(ptr @[[GLOB1]], i32 [[TMP0]]), !dbg [[DBG15:![0-9]+]]
136 // DEBUG1-NEXT: call void @__kmpc_taskgroup(ptr @[[GLOB3:[0-9]+]], i32 [[TMP0]]), !dbg [[DBG16:![0-9]+]]
137 // DEBUG1-NEXT: invoke void @_Z3foov()
138 // DEBUG1-NEXT: to label [[INVOKE_CONT:%.*]] unwind label [[TERMINATE_LPAD:%.*]], !dbg [[DBG17:![0-9]+]]
139 // DEBUG1: invoke.cont:
140 // DEBUG1-NEXT: call void @__kmpc_end_taskgroup(ptr @[[GLOB3]], i32 [[TMP0]]), !dbg [[DBG17]]
141 // DEBUG1-NEXT: [[TMP1:%.*]] = load i8, ptr [[A]], align 1, !dbg [[DBG18:![0-9]+]]
142 // DEBUG1-NEXT: [[CONV:%.*]] = sext i8 [[TMP1]] to i32, !dbg [[DBG18]]
143 // DEBUG1-NEXT: ret i32 [[CONV]], !dbg [[DBG19:![0-9]+]]
144 // DEBUG1: terminate.lpad:
145 // DEBUG1-NEXT: [[TMP2:%.*]] = landingpad { ptr, i32 }
146 // DEBUG1-NEXT: catch ptr null, !dbg [[DBG17]]
147 // DEBUG1-NEXT: [[TMP3:%.*]] = extractvalue { ptr, i32 } [[TMP2]], 0, !dbg [[DBG17]]
148 // DEBUG1-NEXT: call void @__clang_call_terminate(ptr [[TMP3]]) #[[ATTR8:[0-9]+]], !dbg [[DBG17]]
149 // DEBUG1-NEXT: unreachable, !dbg [[DBG17]]
152 // DEBUG1-LABEL: define {{[^@]+}}@__clang_call_terminate
153 // DEBUG1-SAME: (ptr noundef [[TMP0:%.*]]) #[[ATTR5:[0-9]+]] {
154 // DEBUG1-NEXT: [[TMP2:%.*]] = call ptr @__cxa_begin_catch(ptr [[TMP0]]) #[[ATTR3:[0-9]+]]
155 // DEBUG1-NEXT: call void @_ZSt9terminatev() #[[ATTR8]]
156 // DEBUG1-NEXT: unreachable
159 // DEBUG1-LABEL: define {{[^@]+}}@_Z18parallel_taskgroupv
160 // DEBUG1-SAME: () #[[ATTR6:[0-9]+]] !dbg [[DBG20:![0-9]+]] {
161 // DEBUG1-NEXT: entry:
162 // DEBUG1-NEXT: call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB7:[0-9]+]], i32 0, ptr @_Z18parallel_taskgroupv.omp_outlined), !dbg [[DBG21:![0-9]+]]
163 // DEBUG1-NEXT: ret void, !dbg [[DBG22:![0-9]+]]
166 // DEBUG1-LABEL: define {{[^@]+}}@_Z18parallel_taskgroupv.omp_outlined
167 // DEBUG1-SAME: (ptr noalias noundef [[DOTGLOBAL_TID_:%.*]], ptr noalias noundef [[DOTBOUND_TID_:%.*]]) #[[ATTR7:[0-9]+]] personality ptr @__gxx_personality_v0 !dbg [[DBG23:![0-9]+]] {
168 // DEBUG1-NEXT: entry:
169 // DEBUG1-NEXT: [[DOTGLOBAL_TID__ADDR:%.*]] = alloca ptr, align 8
170 // DEBUG1-NEXT: [[DOTBOUND_TID__ADDR:%.*]] = alloca ptr, align 8
171 // DEBUG1-NEXT: store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
172 // DEBUG1-NEXT: store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
173 // DEBUG1-NEXT: [[TMP0:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8, !dbg [[DBG24:![0-9]+]]
174 // DEBUG1-NEXT: [[TMP1:%.*]] = load i32, ptr [[TMP0]], align 4, !dbg [[DBG24]]
175 // DEBUG1-NEXT: call void @__kmpc_taskgroup(ptr @[[GLOB5:[0-9]+]], i32 [[TMP1]]), !dbg [[DBG24]]
176 // DEBUG1-NEXT: invoke void @_Z3foov()
177 // DEBUG1-NEXT: to label [[INVOKE_CONT:%.*]] unwind label [[TERMINATE_LPAD:%.*]], !dbg [[DBG25:![0-9]+]]
178 // DEBUG1: invoke.cont:
179 // DEBUG1-NEXT: call void @__kmpc_end_taskgroup(ptr @[[GLOB5]], i32 [[TMP1]]), !dbg [[DBG25]]
180 // DEBUG1-NEXT: ret void, !dbg [[DBG26:![0-9]+]]
181 // DEBUG1: terminate.lpad:
182 // DEBUG1-NEXT: [[TMP2:%.*]] = landingpad { ptr, i32 }
183 // DEBUG1-NEXT: catch ptr null, !dbg [[DBG25]]
184 // DEBUG1-NEXT: [[TMP3:%.*]] = extractvalue { ptr, i32 } [[TMP2]], 0, !dbg [[DBG25]]
185 // DEBUG1-NEXT: call void @__clang_call_terminate(ptr [[TMP3]]) #[[ATTR8]], !dbg [[DBG25]]
186 // DEBUG1-NEXT: unreachable, !dbg [[DBG25]]
189 // CHECK2-LABEL: define {{[^@]+}}@_Z3foov
190 // CHECK2-SAME: () #[[ATTR0:[0-9]+]] {
191 // CHECK2-NEXT: entry:
192 // CHECK2-NEXT: call void @_Z8mayThrowv()
193 // CHECK2-NEXT: ret void
196 // CHECK2-LABEL: define {{[^@]+}}@main
197 // CHECK2-SAME: () #[[ATTR2:[0-9]+]] {
198 // CHECK2-NEXT: entry:
199 // CHECK2-NEXT: [[RETVAL:%.*]] = alloca i32, align 4
200 // CHECK2-NEXT: [[A:%.*]] = alloca i8, align 1
201 // CHECK2-NEXT: store i32 0, ptr [[RETVAL]], align 4
202 // CHECK2-NEXT: [[OMP_GLOBAL_THREAD_NUM:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB1:[0-9]+]])
203 // CHECK2-NEXT: call void @__kmpc_taskgroup(ptr @[[GLOB1]], i32 [[OMP_GLOBAL_THREAD_NUM]])
204 // CHECK2-NEXT: store i8 2, ptr [[A]], align 1
205 // CHECK2-NEXT: br label [[TASKGROUP_EXIT:%.*]]
206 // CHECK2: taskgroup.exit:
207 // CHECK2-NEXT: call void @__kmpc_end_taskgroup(ptr @[[GLOB1]], i32 [[OMP_GLOBAL_THREAD_NUM]])
208 // CHECK2-NEXT: [[OMP_GLOBAL_THREAD_NUM1:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB1]])
209 // CHECK2-NEXT: call void @__kmpc_taskgroup(ptr @[[GLOB1]], i32 [[OMP_GLOBAL_THREAD_NUM1]])
210 // CHECK2-NEXT: call void @_Z3foov()
211 // CHECK2-NEXT: br label [[TASKGROUP_EXIT2:%.*]]
212 // CHECK2: taskgroup.exit2:
213 // CHECK2-NEXT: call void @__kmpc_end_taskgroup(ptr @[[GLOB1]], i32 [[OMP_GLOBAL_THREAD_NUM1]])
214 // CHECK2-NEXT: [[TMP0:%.*]] = load i8, ptr [[A]], align 1
215 // CHECK2-NEXT: [[CONV:%.*]] = sext i8 [[TMP0]] to i32
216 // CHECK2-NEXT: ret i32 [[CONV]]
219 // CHECK2-LABEL: define {{[^@]+}}@_Z18parallel_taskgroupv
220 // CHECK2-SAME: () #[[ATTR0]] {
221 // CHECK2-NEXT: entry:
222 // CHECK2-NEXT: [[OMP_GLOBAL_THREAD_NUM:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB1]])
223 // CHECK2-NEXT: br label [[OMP_PARALLEL:%.*]]
224 // CHECK2: omp_parallel:
225 // CHECK2-NEXT: call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB1]], i32 0, ptr @_Z18parallel_taskgroupv..omp_par)
226 // CHECK2-NEXT: br label [[OMP_PAR_OUTLINED_EXIT:%.*]]
227 // CHECK2: omp.par.outlined.exit:
228 // CHECK2-NEXT: br label [[OMP_PAR_EXIT_SPLIT:%.*]]
229 // CHECK2: omp.par.exit.split:
230 // CHECK2-NEXT: ret void
233 // CHECK2-LABEL: define {{[^@]+}}@_Z18parallel_taskgroupv..omp_par
234 // CHECK2-SAME: (ptr noalias [[TID_ADDR:%.*]], ptr noalias [[ZERO_ADDR:%.*]]) #[[ATTR5:[0-9]+]] {
235 // CHECK2-NEXT: omp.par.entry:
236 // CHECK2-NEXT: [[TID_ADDR_LOCAL:%.*]] = alloca i32, align 4
237 // CHECK2-NEXT: [[TMP0:%.*]] = load i32, ptr [[TID_ADDR]], align 4
238 // CHECK2-NEXT: store i32 [[TMP0]], ptr [[TID_ADDR_LOCAL]], align 4
239 // CHECK2-NEXT: [[TID:%.*]] = load i32, ptr [[TID_ADDR_LOCAL]], align 4
240 // CHECK2-NEXT: br label [[OMP_PAR_REGION:%.*]]
241 // CHECK2: omp.par.region:
242 // CHECK2-NEXT: [[OMP_GLOBAL_THREAD_NUM1:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB1]])
243 // CHECK2-NEXT: call void @__kmpc_taskgroup(ptr @[[GLOB1]], i32 [[OMP_GLOBAL_THREAD_NUM1]])
244 // CHECK2-NEXT: call void @_Z3foov()
245 // CHECK2-NEXT: br label [[TASKGROUP_EXIT:%.*]]
246 // CHECK2: taskgroup.exit:
247 // CHECK2-NEXT: call void @__kmpc_end_taskgroup(ptr @[[GLOB1]], i32 [[OMP_GLOBAL_THREAD_NUM1]])
248 // CHECK2-NEXT: br label [[OMP_PAR_REGION_PARALLEL_AFTER:%.*]]
249 // CHECK2: omp.par.region.parallel.after:
250 // CHECK2-NEXT: br label [[OMP_PAR_PRE_FINALIZE:%.*]]
251 // CHECK2: omp.par.pre_finalize:
252 // CHECK2-NEXT: br label [[OMP_PAR_OUTLINED_EXIT_EXITSTUB:%.*]]
253 // CHECK2: omp.par.outlined.exit.exitStub:
254 // CHECK2-NEXT: ret void