[flang-commits] [flang] e5aa6ee - [flang][OpenMP] Verify support for private/firstprivate on unstructured sections

Nimish Mishra via flang-commits flang-commits at lists.llvm.org
Thu Jun 1 03:36:38 PDT 2023


Author: Nimish Mishra
Date: 2023-06-01T16:05:23+05:30
New Revision: e5aa6eeb4c474de99c44a667e3852f90e3774396

URL: https://github.com/llvm/llvm-project/commit/e5aa6eeb4c474de99c44a667e3852f90e3774396
DIFF: https://github.com/llvm/llvm-project/commit/e5aa6eeb4c474de99c44a667e3852f90e3774396.diff

LOG: [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

Added: 
    

Modified: 
    flang/test/Lower/OpenMP/sections.f90

Removed: 
    


################################################################################
diff  --git a/flang/test/Lower/OpenMP/sections.f90 b/flang/test/Lower/OpenMP/sections.f90
index 02ab64d9fa17..fc7029e2c9d7 100644
--- a/flang/test/Lower/OpenMP/sections.f90
+++ b/flang/test/Lower/OpenMP/sections.f90
@@ -232,6 +232,8 @@ subroutine lastprivate()
 !CHECK: omp.terminator
 !CHECK: }
 !CHECK: omp.terminator
+!CHECK: }
+!CHECK: return
 !CHECK: }
 
     !$omp sections lastprivate(x)
@@ -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


        


More information about the flang-commits mailing list