[llvm] [OFFLOAD] Fix an issue with nested close, alloc mapping when using USM (PR #208122)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 27 20:54:02 PDT 2026


fineg74 wrote:

> Please add a "positive" test ensuring that we don't lose the close optimization when an unrelated item is previously mapped, like:
> 
> ```c++
> // This is an implementation-specific test (it does not reflect official OpenMP expectations).
> // The test is to ensure that we do the optimization to "allocate" a new device copy
> // for maps with `close` modifier, but only when a matching entry doesn't
> // already exist on the device.
> 
> int x, y;
> #pragma omp requires unified_shared_memory
> 
> int main() {
> #pragma omp target data map(tofrom: x)
> #pragma omp target map(close, tofrom: x, y) map(from: xaddr_device, yaddr_device)
> {
>   xaddr_device = &x;
>   yaddr_device = &y;
> }
> 
> assert(xaddr_device == &x && ...)
> assert(yaddr_device != &y && ...)
> }
> ```

Added a test

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


More information about the llvm-commits mailing list