[OpenMP] Fix `target data` exit for array extension
authorJoel E. Denny <jdenny.ornl@gmail.com>
Wed, 5 Aug 2020 20:48:04 +0000 (16:48 -0400)
committerJoel E. Denny <jdenny.ornl@gmail.com>
Wed, 5 Aug 2020 20:51:25 +0000 (16:51 -0400)
commit8c8bb128dfd09f84b27b9e732cf1355582b1d019
tree46d70651455661908cfdbca8b14fe01447375d25
parent41b1aefecb9447620dd182b0352abed0df05665c
[OpenMP] Fix `target data` exit for array extension

For example:

```
 #pragma omp target data map(tofrom:arr[0:100])
 {
   #pragma omp target exit data map(delete:arr[0:100])
   #pragma omp target enter data map(alloc:arr[98:2])
 }
```

Without this patch, the transfer at the end of the target data region
is broken and fails depending on the target device.  According to my
read of the spec, the transfer shouldn't even be attempted because
`arr[0:100]` isn't (fully) present there.  To fix that, this patch
makes `DeviceTy::getTgtPtrBegin` return null for this case.

Reviewed By: grokos

Differential Revision: https://reviews.llvm.org/D85342
openmp/libomptarget/src/omptarget.cpp
openmp/libomptarget/test/mapping/target_data_array_extension_at_exit.c [new file with mode: 0644]