diff --git a/flang/test/Lower/OpenMP/sections.f90 b/flang/test/Lower/OpenMP/sections.f90 --- a/flang/test/Lower/OpenMP/sections.f90 +++ b/flang/test/Lower/OpenMP/sections.f90 @@ -231,6 +231,7 @@ !CHECK: fir.store %[[loaded_value]] to %[[X]] : !fir.ref !CHECK: omp.terminator !CHECK: } +!CHECK: return !CHECK: } !$omp sections lastprivate(x) !$omp section @@ -238,3 +239,45 @@ 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 +!CHECK: %[[constant:.*]] = arith.constant 1.000000e+00 : f32 +!CHECK: %[[result:.*]] = arith.addf %[[INNER_PRIVATE_X]], %[[constant]] fastmath : f32 +!CHECK: fir.store %[[result]] to %[[PRIVATE_X]] : !fir.ref +!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 +!CHECK: fir.store %[[temp]] to %[[PRIVATE_X]] : !fir.ref +!CHECK: cf.br ^bb1 +!CHECK: ^bb1: // pred: ^bb0 +!CHECK: %[[INNER_PRIVATE_X:.*]] = fir.load %[[PRIVATE_X]] : !fir.ref +!CHECK: %[[constant:.*]] = arith.constant 1.000000e+00 : f32 +!CHECK: %[[result:.*]] = arith.addf %[[INNER_PRIVATE_X]], %[[constant]] fastmath : f32 +!CHECK: fir.store %[[result]] to %[[PRIVATE_X]] : !fir.ref +!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