[OPENMP50]Codegen for lastprivate conditional list items.
authorAlexey Bataev <a.bataev@hotmail.com>
Fri, 27 Dec 2019 14:44:43 +0000 (09:44 -0500)
committerAlexey Bataev <a.bataev@hotmail.com>
Thu, 2 Jan 2020 21:43:00 +0000 (16:43 -0500)
commita58da1a2ff039dd3bb4c43db3919995cf4a74cc7
tree5406d1d48fa4cc0a70fd8cb4aa8668bac245b627
parentf83801fb2a4064d666cf8c17d716376a99e4a555
[OPENMP50]Codegen for lastprivate conditional list items.

Added codegen support for lastprivate conditional. According to the
standard, if  when the conditional modifier appears on the clause, if an
assignment to a list item is encountered in the construct then the
original list item is assigned the value that is assigned to the new
list item in the sequentially last iteration or lexically last section
in which such an assignment is encountered.
We look for the assignment operations and check if the left side
references lastprivate conditional variable. Then the next code is
emitted:
if (last_iv_a <= iv) {
  last_iv_a = iv;
  last_a = lp_a;
}

At the end the implicit barrier is generated to wait for the end of all
threads and then in the check for the last iteration the private copy is
assigned the last value.

if (last_iter) {
  lp_a = last_a; // <--- new code
  a = lp_a;      // <--- store of private value to the original  variable.
}
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprComplex.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/for_lastprivate_codegen.cpp
clang/test/OpenMP/simd_codegen.cpp