diff options
| author | Alexey Bataev <a.bataev@hotmail.com> | 2019-06-21 15:08:30 +0000 |
|---|---|---|
| committer | Alexey Bataev <a.bataev@hotmail.com> | 2019-06-21 15:08:30 +0000 |
| commit | e0eb66bbff5e4307c54e4f5c52e711b4b1b05126 (patch) | |
| tree | 97710dbd81dbe43fa6d6ca300aa565aa1d413bfa /clang | |
| parent | b0ba049f58b38f273b9eb531d9da1df30ad5033f (diff) | |
| download | bcm5719-llvm-e0eb66bbff5e4307c54e4f5c52e711b4b1b05126.tar.gz bcm5719-llvm-e0eb66bbff5e4307c54e4f5c52e711b4b1b05126.zip | |
[OPENMP]Fix PR42159: do not capture threadprivate variables.
The threadprivate variables should not be captured in the outlined
regions, otherwise it leads to the compiler crash.
llvm-svn: 364061
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 7 | ||||
| -rw-r--r-- | clang/test/OpenMP/parallel_copyin_codegen.cpp | 5 |
2 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 19057eb3986..b531d31c1ca 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -1866,11 +1866,14 @@ VarDecl *Sema::isOpenMPCapturedDecl(ValueDecl *D, bool CheckScopeInfo, DSAStack->getTopDSA(D, DSAStack->isClauseParsingMode()); if (DVarPrivate.CKind != OMPC_unknown && isOpenMPPrivate(DVarPrivate.CKind)) return VD ? VD : cast<VarDecl>(DVarPrivate.PrivateCopy->getDecl()); + // Threadprivate variables must not be captured. + if (isOpenMPThreadPrivate(DVarPrivate.CKind)) + return nullptr; + // The variable is not private or it is the variable in the directive with + // default(none) clause and not used in any clause. DVarPrivate = DSAStack->hasDSA(D, isOpenMPPrivate, [](OpenMPDirectiveKind) { return true; }, DSAStack->isClauseParsingMode()); - // The variable is not private or it is the variable in the directive with - // default(none) clause and not used in any clause. if (DVarPrivate.CKind != OMPC_unknown || (VD && DSAStack->getDefaultDSA() == DSA_none)) return VD ? VD : cast<VarDecl>(DVarPrivate.PrivateCopy->getDecl()); diff --git a/clang/test/OpenMP/parallel_copyin_codegen.cpp b/clang/test/OpenMP/parallel_copyin_codegen.cpp index 5e056b9ccb0..8fa9edd2c1a 100644 --- a/clang/test/OpenMP/parallel_copyin_codegen.cpp +++ b/clang/test/OpenMP/parallel_copyin_codegen.cpp @@ -239,8 +239,8 @@ int main() { vec[0] = t_var; s_arr[0] = var; } -#pragma omp parallel copyin(t_var) - {} +#pragma omp parallel copyin(t_var) default(none) + ++t_var; return tmain<int>(); #endif } @@ -363,6 +363,7 @@ int main() { // TLS-CHECK: [[DONE]] // CHECK: call {{.*}}void @__kmpc_barrier(%{{.+}}* [[IMPLICIT_BARRIER_LOC]], i32 [[GTID]]) +// CHECK: add nsw i32 %{{.+}}, 1 // CHECK: ret void // TLS-CHECK: [[GTID_ADDR:%.+]] = load i32*, i32** [[GTID_ADDR_ADDR]], |

