[Mlir-commits] [flang] [llvm] [mlir] [Flang][OpenMP] Add support for scope construct (PR #193098)
Tom Eccles
llvmlistbot at llvm.org
Tue Apr 21 07:54:07 PDT 2026
================
@@ -0,0 +1,111 @@
+! This test checks the lowering of OpenMP scope construct.
+
+! RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=52 %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 %s -o - | FileCheck %s
+
+! Module-level declarations emitted before any function body.
+
+! CHECK-LABEL: omp.private {type = firstprivate} @_QFomp_scope_firstprivateEi_firstprivate_i32 : i32 copy {
+! CHECK: fir.load %{{.*}} : !fir.ref<i32>
+! CHECK: hlfir.assign %{{.*}} to %{{.*}} : i32, !fir.ref<i32>
+! CHECK: omp.yield
+
+! CHECK-LABEL: omp.declare_reduction @add_reduction_i32 : i32 init {
+! CHECK: arith.constant 0 : i32
+! CHECK: omp.yield
+! CHECK-LABEL: } combiner {
+! CHECK: arith.addi
+! CHECK: omp.yield
+
+! CHECK: omp.private {type = private} @_QFomp_scope_privateEi_private_i32 : i32
+
+! CHECK-LABEL: func @_QPomp_scope_basic
+subroutine omp_scope_basic()
+ integer :: x
+ ! CHECK: hlfir.declare %{{.*}} {uniq_name = "_QFomp_scope_basicEx"}
+ x = 10
+
+ ! CHECK: omp.scope {
+ !$omp scope
+ print *, "In scope", x
+ ! CHECK: omp.terminator
+ ! CHECK: }
+ !$omp end scope
+end subroutine
+
+! CHECK-LABEL: func @_QPomp_scope_nowait
+subroutine omp_scope_nowait()
+ integer :: x
+ ! CHECK: hlfir.declare %{{.*}} {uniq_name = "_QFomp_scope_nowaitEx"}
+ x = 10
+
+ ! CHECK: omp.scope nowait {
+ !$omp scope
+ print *, "In scope", x
+ ! CHECK: omp.terminator
+ ! CHECK: }
+ !$omp end scope nowait
+end subroutine
+
+! CHECK-LABEL: func @_QPomp_scope_private
+subroutine omp_scope_private()
+ integer :: i
+ ! CHECK: hlfir.declare %{{.*}} {uniq_name = "_QFomp_scope_privateEi"}
+ i = 10
+
+ ! CHECK: omp.scope private(@_QFomp_scope_privateEi_private_i32 %{{.*}}#0 -> %[[IARG:.*]] : !fir.ref<i32>) {
+ ! CHECK: hlfir.declare %[[IARG]] {uniq_name = "_QFomp_scope_privateEi"}
+ !$omp scope private(i)
+ print *, "omp scope", i
----------------
tblah wrote:
Please could you check that the usage of `i` inside SCOPE is using `%[[IARG]]`. If `print` codegen is inconveniently messy you can just use `call do_something(i)`
(and for other tests below)
https://github.com/llvm/llvm-project/pull/193098
More information about the Mlir-commits
mailing list