[OPENMP] Codegen for 'copyprivate' clause ('single' directive).
authorAlexey Bataev <a.bataev@hotmail.com>
Mon, 23 Mar 2015 06:18:07 +0000 (06:18 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Mon, 23 Mar 2015 06:18:07 +0000 (06:18 +0000)
commita63048e4fd2936e600a1268651a4f2ad981309d0
tree571fb385d651af11e25506fec4590f3aaca5ecb4
parent1565992679f173ca9517637ac3aeca4636b624ff
[OPENMP] Codegen for 'copyprivate' clause ('single' directive).

If there is at least one 'copyprivate' clause is associated with the single directive, the following code is generated:

```
i32 did_it = 0;                                  \\ for 'copyprivate' clause
if(__kmpc_single(ident_t *, gtid)) {
  SingleOpGen();
  __kmpc_end_single(ident_t *, gtid);
  did_it = 1;                                    \\ for 'copyprivate' clause
}
<copyprivate_list>[0] = &var0;
...
<copyprivate_list>[n] = &varn;
call __kmpc_copyprivate(ident_t *, gtid, <copyprivate_list_size>,
                        <copyprivate_list>, <copy_func>, did_it);

...

void<copy_func>(void *LHSArg, void *RHSArg) {
  Dst = (void * [n])(LHSArg);
  Src = (void * [n])(RHSArg);
  Dst[0] = Src[0];
  ... Dst[n] = Src[n];
}
```
All list items from all 'copyprivate' clauses are gathered into single <copyprivate list> (<copyprivate_list_size> is a size in bytes of this list) and <copy_func> is used to propagate values of private or threadprivate variables from the 'single' region to other implicit threads from outer 'parallel' region.
Differential Revision: http://reviews.llvm.org/D8410

llvm-svn: 232932
15 files changed:
clang/include/clang/AST/DataRecursiveASTVisitor.h
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/lib/AST/Stmt.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/test/OpenMP/single_codegen.cpp
clang/test/OpenMP/single_copyprivate_messages.cpp
clang/tools/libclang/CIndex.cpp