[flang-commits] [clang] [flang] [mlir] [Flang][OpenMP] Lower DECLARE TARGET INDIRECT clause (PR #208387)

via flang-commits flang-commits at lists.llvm.org
Fri Aug 14 02:27:10 PDT 2026


================
@@ -0,0 +1,39 @@
+! This test checks the lowering of the OpenMP INDIRECT clause when used with the
+! DECLARE TARGET directive, together with an indirect call (through a procedure
+! pointer) from within a target region.
+
+! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 -fopenmp-is-target-device %s -o - | FileCheck %s
+
+module functions
+  implicit none
+
+  interface
+    function func() result(i)
+      character(1) :: i
+    end function
+  end interface
+
+contains
+  ! CHECK: func.func @_QMfunctionsPfunc1({{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (enter), automap = false, indirect = true>}
+  function func1() result(i)
+    !$omp declare target enter(func1) indirect(.true.)
+    character(1) :: i
+    i = 'a'
+    return
+  end function
+end module
+
+program main
+  use functions
+  implicit none
+  procedure (func), pointer :: ptr1=>func1
+  character(1) :: val1
+
+  ! CHECK-LABEL: func.func @_QQmain()
+  ! CHECK: omp.target
----------------
blazie2004 wrote:

Added checks for the fir.load of the procedure pointer, the fir.box_addr producing the callable address, and that address being the callee of the fir.call.

https://github.com/llvm/llvm-project/pull/208387


More information about the flang-commits mailing list