[flang-commits] [flang] [llvm] [mlir] [Flang][OpenMP] Fix Fortran automap handling (PR #162501)

via flang-commits flang-commits at lists.llvm.org
Tue Jun 2 00:09:48 PDT 2026


================
@@ -0,0 +1,27 @@
+! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=60 %s -o - | FileCheck %s
+
+program automap_program
+   integer, allocatable, target :: automap_array(:)
+   !$omp declare target enter(automap:automap_array)
+
+   allocate (automap_array(10))
+
+   !$omp target
----------------
agozillon wrote:

Not sure if you will run into this, but I have a PR that fixes enter map of variables for declare target here: https://github.com/llvm/llvm-project/pull/200248 and a couple of other bugs. It would be better to utilise declare target to in the meantime (and usm in any tests you may be using to verify with).

Also of note, is that you might run into the fact in your tests that any map into that target is going to require an implicit always map type, as I believe declare target to/enter variables have an infinite reference count which means they ignore most map requests without an always modifier applied. Saying that, declare target should I believe only apply to the descriptor in this case, so it likely by default already has always applied to its mapping (from what I can see above, and that's the default behaviour we have I think)  :-)

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


More information about the flang-commits mailing list