[PATCH] D84182: [OPENMP]Fix PR46012: declare target pointer cannot be accessed in target region.

Alexey Bataev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 28 06:40:43 PDT 2020


ABataev added a comment.

In D84182#2178560 <https://reviews.llvm.org/D84182#2178560>, @ye-luo wrote:

> In D84182#2173578 <https://reviews.llvm.org/D84182#2173578>, @grokos wrote:
>
>> @ABataev:
>>
>> After this patch was committed, I tried to run the following example:
>>
>>   #include <stdio.h>
>>   
>>   int *yptr;
>>   
>>   int main() {
>>     int y[10];
>>     y[1] = 1;
>>     yptr = &y[0];
>>   
>>     printf("&yptr = %p\n", &yptr);
>>     printf("&y[0] = %p\n", &y[0]);
>>   
>>     #pragma omp target data map(to: yptr[0:5])
>>     #pragma omp target
>>     {
>>       printf("y = %d\n", yptr[1]);
>>       yptr[1] = 10;
>>       printf("y = %d\n", yptr[1]);
>>     }
>>   
>>     printf("y = %d\n", yptr[1]);
>>     return 0;
>>   }
>>
>> The arguments clang generates are:
>>
>>   1) base = &y[0], begin = &yptr, size = 8, type = TARGET_PARAM | TO
>>   2) base = &yptr, begin = &y[0], size = 8, type = PTR_AND_OBJ | TO
>>
>> The second argument is correct, the first argument doesn't make much sense. I believe it should have its base set to &yptr, not &y[0].
>> y[0] is not the base for anything, it's only the pointee object.
>
> I hit the same issue and it results incorrect mapping.
> https://bugs.llvm.org/show_bug.cgi?id=46868
> In addition, only yptr is touched inside the target region. After this patch, two mappings instead of one occurs.

The fix is almost ready, working on tests update


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84182/new/

https://reviews.llvm.org/D84182



More information about the cfe-commits mailing list