[OPENMP]Add support for allocate vars in untied tasks.
authorAlexey Bataev <a.bataev@hotmail.com>
Tue, 15 Sep 2020 15:21:47 +0000 (11:21 -0400)
committerAlexey Bataev <alexey.bataev@ibm.com>
Tue, 15 Sep 2020 17:39:14 +0000 (13:39 -0400)
commit738bab743b5c6cfcf1a1feb116de9e35a3f1e326
tree6378f13401fce65aeb800c271cc8da93d59f6e3b
parent3bc3983f229f9277d5bea3692b691f72ab8740dd
[OPENMP]Add support for allocate vars in untied tasks.

Local vars, marked with pragma allocate, mustbe allocate by the call of
the runtime function and cannot be allocated as other local variables.
Instead, we allocate a space for the pointer in private record and store
the address, returned by kmpc_alloc call in this pointer.
So, for untied tasks

```
 #pragma omp task untied
 {
   S s;
    #pragma omp allocate(s) allocator(allocator)
   s = x;
 }
```
compiler generates something like this:
```
struct task_with_privates {
  S *ptr;
};

void entry(task_with_privates *p) {
  S *s = p->s;
  switch(partid) {
  case 1:
    p->s = (S*)kmpc_alloc();
    kmpc_omp_task();
    br exit;
  case 2:
    *s = x;
    kmpc_omp_task();
    br exit;
  case 2:
    ~S(s);
    kmpc_free((void*)s);
    br exit;
  }
exit:
}
```

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D86558
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/allocate_codegen.cpp
clang/test/OpenMP/for_lastprivate_codegen.cpp
clang/test/OpenMP/for_linear_codegen.cpp
clang/test/OpenMP/for_reduction_codegen_UDR.cpp
clang/test/OpenMP/parallel_firstprivate_codegen.cpp
clang/test/OpenMP/parallel_private_codegen.cpp
clang/test/OpenMP/task_codegen.cpp