]> granicus.if.org Git - clang/commit
[OPENMP] Codegen for 'lastprivate' clause in 'for' directive.
authorAlexey Bataev <a.bataev@hotmail.com>
Thu, 16 Apr 2015 04:54:05 +0000 (04:54 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Thu, 16 Apr 2015 04:54:05 +0000 (04:54 +0000)
commit5a78b2480c717cbbf91747a154e3556b40ae8b76
tree8697923cf30b28b8beb6bf705d989eb7579684cf
parentb4a4ab9bdd5e0cbb32588aee51a2c67f9a18373f
[OPENMP] Codegen for 'lastprivate' clause in 'for' directive.

#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.

Differential Revision: http://reviews.llvm.org/D8658

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235074 91177308-0d34-0410-b5e6-96231b3b80d8
19 files changed:
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 [new file with mode: 0644]
test/OpenMP/for_lastprivate_messages.cpp
test/OpenMP/for_simd_lastprivate_messages.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