Skip to content

Commit

Permalink
[flang][OpenMP] Verify support for private/firstprivate on unstructur…
Browse files Browse the repository at this point in the history
…ed sections

Verification of support for lowering private/firstprivate clauses
on unstructured sections.

Differential Revision: https://reviews.llvm.org/D145352

Reviewed By: TIFitis
  • Loading branch information
NimishMishra committed Jun 1, 2023
1 parent 453e02c commit e5aa6ee
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions flang/test/Lower/OpenMP/sections.f90
Expand Up @@ -232,6 +232,8 @@ subroutine lastprivate()
!CHECK: omp.terminator
!CHECK: }
!CHECK: omp.terminator
!CHECK: }
!CHECK: return
!CHECK: }

!$omp sections lastprivate(x)
Expand All @@ -240,3 +242,45 @@ subroutine lastprivate()
30 x = x + 1
!$omp end sections
end subroutine

subroutine unstructured_sections_privatization()
!CHECK: %[[X:.*]] = fir.alloca f32 {bindc_name = "x", uniq_name = "_QFunstructured_sections_privatizationEx"}
!CHECK: omp.sections {
!CHECK: omp.section {
!CHECK: %[[PRIVATE_X:.*]] = fir.alloca f32 {bindc_name = "x", pinned, uniq_name = "_QFunstructured_sections_privatizationEx"}
!CHECK: cf.br ^bb1
!CHECK: ^bb1: // pred: ^bb0
!CHECK: %[[INNER_PRIVATE_X:.*]] = fir.load %[[PRIVATE_X]] : !fir.ref<f32>
!CHECK: %[[constant:.*]] = arith.constant 1.000000e+00 : f32
!CHECK: %[[result:.*]] = arith.addf %[[INNER_PRIVATE_X]], %[[constant]] fastmath<contract> : f32
!CHECK: fir.store %[[result]] to %[[PRIVATE_X]] : !fir.ref<f32>
!CHECK: omp.terminator
!CHECK: }
!CHECK: omp.terminator
!CHECK: }
!$omp sections private(x)
!$omp section
goto 40
40 x = x + 1
!$omp end sections
!CHECK: omp.sections {
!CHECK: omp.section {
!CHECK: %[[PRIVATE_X:.*]] = fir.alloca f32 {bindc_name = "x", pinned, uniq_name = "_QFunstructured_sections_privatizationEx"}
!CHECK: %[[temp:.*]] = fir.load %[[X]] : !fir.ref<f32>
!CHECK: fir.store %[[temp]] to %[[PRIVATE_X]] : !fir.ref<f32>
!CHECK: cf.br ^bb1
!CHECK: ^bb1: // pred: ^bb0
!CHECK: %[[INNER_PRIVATE_X:.*]] = fir.load %[[PRIVATE_X]] : !fir.ref<f32>
!CHECK: %[[constant:.*]] = arith.constant 1.000000e+00 : f32
!CHECK: %[[result:.*]] = arith.addf %[[INNER_PRIVATE_X]], %[[constant]] fastmath<contract> : f32
!CHECK: fir.store %[[result]] to %[[PRIVATE_X]] : !fir.ref<f32>
!CHECK: omp.terminator
!CHECK: }
!CHECK: omp.terminator
!CHECK: }
!$omp sections firstprivate(x)
!$omp section
goto 50
50 x = x + 1
!$omp end sections
end subroutine

0 comments on commit e5aa6ee

Please sign in to comment.