[PATCH] [OPENMP] Codegen for 'lastprivate' clause in 'for' directive.

Alexey Bataev a.bataev at hotmail.com
Fri Mar 27 05:04:58 PDT 2015


Hi rjmccall, hfinkel, fraggamuffin, ejstotzer,

```
#pragma omp for lastprivate(<var>)
for (i = a; i < b; ++b)
<BODY>;
```
This construct is translated into something like:
```
<last_iter> = alloca i32
<lastprivate_var> = alloca <type>
<last_iter> = 0
; No initializer for simple variables or a default constructor is called for objects.
; For arrays perform element by element initialization by the call of the default constructor.
...
OMP_FOR_START(...,<last_iter>, ..); sets <last_iter> to 1 if this is the last iteration.
<BODY>
...
OMP_FOR_END
if (<last_iter> != 0) {
<var> = <lastprivate_var> ; Update original variable with the lastprivate value.
}
call __kmpc_cancel_barrier() ; an implicit barrier to avoid possible data race.
```

http://reviews.llvm.org/D8658

Files:
  include/clang/AST/DataRecursiveASTVisitor.h
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  lib/AST/Stmt.cpp
  lib/AST/StmtProfile.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaOpenMP.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/for_lastprivate_codegen.cpp
  test/OpenMP/for_lastprivate_messages.cpp
  test/OpenMP/for_simd_lastprivate_messages.cpp
  test/OpenMP/parallel_firstprivate_codegen.cpp
  test/OpenMP/parallel_for_lastprivate_messages.cpp
  test/OpenMP/parallel_for_simd_lastprivate_messages.cpp
  test/OpenMP/parallel_sections_lastprivate_messages.cpp
  test/OpenMP/sections_lastprivate_messages.cpp
  test/OpenMP/simd_lastprivate_messages.cpp
  tools/libclang/CIndex.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8658.22785.patch
Type: text/x-patch
Size: 91887 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150327/3d96fae4/attachment.bin>


More information about the cfe-commits mailing list