mirror of
https://github.com/clang-retro/llvm.git
synced 2026-11-28 13:19:18 -08:00
Reland of #233650, reverted in #243904 after two buildbot failures. The PR has two commits, so that the fix can be reviewed on its own: 1. `406b85fd7023`: revert of the revert PR 243904. 2. `dd7d863ac958`: the fix and new tests for the buildbot failures. The fix resolved the nvptx/sycl buildbot fails. Verified via https://lab.llvm.org/buildbot/#/builders/239/builds/1050, https://lab.llvm.org/buildbot/#/builders/225/builds/26443. ----- #### Original description Since OpenMP 6.1, an attached pointer may be re-pointed on the host. A FROM of its containing storage must then keep the host's current value: ```c S s = {&a[0], 0}; #pragma omp target enter data map(to : s, s.p[0 : 1]) s.p = &a[1]; // host only #pragma omp target exit data map(from : s) // main: s.p == &a[0], the value saved at attach time // now: s.p == &a[1] ``` The runtime now saves the host pointers that a FROM transfer overwrites right before the transfer, and writes them back once the transfer completes. Previously it wrote the attach-time value back after every FROM entry, even when the FROM was skipped (ref count > 1) or did not cover the pointer. Tests: `offload/test/mapping/attach_host_ptr_from_*.c`, plus two Fortran tests from #229966 (co-authored with @agozillon). On a forced `amdgpu-clang-flang` build ([#9094](https://lab.llvm.org/buildbot/#/builders/234/builds/9094)), the C tests pass on amdgpu and x86_64 and `derived_type_pointer_repointed_host_kept.f90` passes on amdgpu; `derived_type_allocatable_skipped_from_no_restore.f90` needs a `libomptarget-debug` runtime and was skipped. The only two `check-offload` failures there also fail on main ([#9093](https://lab.llvm.org/buildbot/#/builders/234/builds/9093)). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>