Skip to content

Commit e5aa6ee

Browse files
committed
[flang][OpenMP] Verify support for private/firstprivate on unstructured sections
Verification of support for lowering private/firstprivate clauses on unstructured sections. Differential Revision: https://reviews.llvm.org/D145352 Reviewed By: TIFitis
1 parent 453e02c commit e5aa6ee

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

flang/test/Lower/OpenMP/sections.f90

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ subroutine lastprivate()
232232
!CHECK: omp.terminator
233233
!CHECK: }
234234
!CHECK: omp.terminator
235+
!CHECK: }
236+
!CHECK: return
235237
!CHECK: }
236238

237239
!$omp sections lastprivate(x)
@@ -240,3 +242,45 @@ subroutine lastprivate()
240242
30 x = x + 1
241243
!$omp end sections
242244
end subroutine
245+
246+
subroutine unstructured_sections_privatization()
247+
!CHECK: %[[X:.*]] = fir.alloca f32 {bindc_name = "x", uniq_name = "_QFunstructured_sections_privatizationEx"}
248+
!CHECK: omp.sections {
249+
!CHECK: omp.section {
250+
!CHECK: %[[PRIVATE_X:.*]] = fir.alloca f32 {bindc_name = "x", pinned, uniq_name = "_QFunstructured_sections_privatizationEx"}
251+
!CHECK: cf.br ^bb1
252+
!CHECK: ^bb1: // pred: ^bb0
253+
!CHECK: %[[INNER_PRIVATE_X:.*]] = fir.load %[[PRIVATE_X]] : !fir.ref<f32>
254+
!CHECK: %[[constant:.*]] = arith.constant 1.000000e+00 : f32
255+
!CHECK: %[[result:.*]] = arith.addf %[[INNER_PRIVATE_X]], %[[constant]] fastmath<contract> : f32
256+
!CHECK: fir.store %[[result]] to %[[PRIVATE_X]] : !fir.ref<f32>
257+
!CHECK: omp.terminator
258+
!CHECK: }
259+
!CHECK: omp.terminator
260+
!CHECK: }
261+
!$omp sections private(x)
262+
!$omp section
263+
goto 40
264+
40 x = x + 1
265+
!$omp end sections
266+
!CHECK: omp.sections {
267+
!CHECK: omp.section {
268+
!CHECK: %[[PRIVATE_X:.*]] = fir.alloca f32 {bindc_name = "x", pinned, uniq_name = "_QFunstructured_sections_privatizationEx"}
269+
!CHECK: %[[temp:.*]] = fir.load %[[X]] : !fir.ref<f32>
270+
!CHECK: fir.store %[[temp]] to %[[PRIVATE_X]] : !fir.ref<f32>
271+
!CHECK: cf.br ^bb1
272+
!CHECK: ^bb1: // pred: ^bb0
273+
!CHECK: %[[INNER_PRIVATE_X:.*]] = fir.load %[[PRIVATE_X]] : !fir.ref<f32>
274+
!CHECK: %[[constant:.*]] = arith.constant 1.000000e+00 : f32
275+
!CHECK: %[[result:.*]] = arith.addf %[[INNER_PRIVATE_X]], %[[constant]] fastmath<contract> : f32
276+
!CHECK: fir.store %[[result]] to %[[PRIVATE_X]] : !fir.ref<f32>
277+
!CHECK: omp.terminator
278+
!CHECK: }
279+
!CHECK: omp.terminator
280+
!CHECK: }
281+
!$omp sections firstprivate(x)
282+
!$omp section
283+
goto 50
284+
50 x = x + 1
285+
!$omp end sections
286+
end subroutine

0 commit comments

Comments
 (0)