[llvm] [OpenMP][Offload] Handle `present/to/from` when a different entry did `alloc/delete`. (PR #165494)

Robert Imschweiler via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 13 01:51:11 PST 2026


================
@@ -0,0 +1,48 @@
+// RUN: %libomptarget-compile-generic
+// RUN: %libomptarget-run-generic 2>&1 \
+// RUN: | %fcheck-generic -check-prefix=CHECK
+// RUN: env LIBOMPTARGET_DEBUG=1 %libomptarget-run-generic 2>&1 \
+// RUN: | %fcheck-generic -check-prefix=DEBUG
+// REQUIRES: libomptarget-debug
+
+// The "present" check should pass on the "target" construct (2),
+// and there should be no "to" transfer, because the pointee "x" is already
+// present (because of (1)).
+// However, there should be a "from" transfer at the end of (2) because of the
+// "delete" on the mapper.
+
+// FIXME: This currently fails, but should start passing once ATTACH-style maps
+// are enabled for mappers (#166874). UNSUPPORTED: true
+
+#include <stdio.h>
+
+typedef struct {
+  int *p;
+  int *q;
+} S;
+#pragma omp declare mapper(my_mapper : S s) map(alloc : s.p)                   \
+    map(alloc, present : s.p[0 : 10]) map(delete : s.q[ : ])                   \
----------------
ro-i wrote:

```suggestion
    map(present, alloc : s.p[0 : 10]) map(delete : s.q[0:10])                   \
```
(order of present and alloc + `s.q` afaik needs explicit bounds since it's not an array but a pointer)

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


More information about the llvm-commits mailing list