Author: hans Date: Mon Jul 22 10:45:30 2019 New Revision: 366706 URL: http://llvm.org/viewvc/llvm-project?rev=366706&view=rev Log: Merging r366483: ------------------------------------------------------------------------ r366483 | abataev | 2019-07-18 21:40:24 +0200 (Thu, 18 Jul 2019) | 6 lines
[OPENMP]Fix sharing of threadprivate variables with TLS support. If the threadprivate variable is used in the copyin clause on inner parallel directive with TLS support, we capture this variable in all outer OpenMP scopes. It leads to the fact that in all scopes we're working with the original variable, not the threadprivate copies. ------------------------------------------------------------------------ Modified: cfe/branches/release_90/ (props changed) cfe/branches/release_90/lib/Sema/SemaOpenMP.cpp cfe/branches/release_90/test/OpenMP/parallel_copyin_codegen.cpp Propchange: cfe/branches/release_90/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Mon Jul 22 10:45:30 2019 @@ -1,4 +1,4 @@ /cfe/branches/type-system-rewrite:134693-134817 -/cfe/trunk:366429,366474,366480,366511 +/cfe/trunk:366429,366474,366480,366483,366511 /cfe/trunk/test:170344 /cfe/trunk/test/SemaTemplate:126920 Modified: cfe/branches/release_90/lib/Sema/SemaOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_90/lib/Sema/SemaOpenMP.cpp?rev=366706&r1=366705&r2=366706&view=diff ============================================================================== --- cfe/branches/release_90/lib/Sema/SemaOpenMP.cpp (original) +++ cfe/branches/release_90/lib/Sema/SemaOpenMP.cpp Mon Jul 22 10:45:30 2019 @@ -1882,6 +1882,13 @@ bool Sema::isOpenMPPrivateDecl(const Val !isOpenMPSimdDirective(DSAStack->getCurrentDirective())) return true; } + if (const auto *VD = dyn_cast<VarDecl>(D)) { + if (DSAStack->isThreadPrivate(const_cast<VarDecl *>(VD)) && + DSAStack->isForceVarCapturing() && + !DSAStack->hasExplicitDSA( + D, [](OpenMPClauseKind K) { return K == OMPC_copyin; }, Level)) + return true; + } return DSAStack->hasExplicitDSA( D, [](OpenMPClauseKind K) { return K == OMPC_private; }, Level) || (DSAStack->isClauseParsingMode() && Modified: cfe/branches/release_90/test/OpenMP/parallel_copyin_codegen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_90/test/OpenMP/parallel_copyin_codegen.cpp?rev=366706&r1=366705&r2=366706&view=diff ============================================================================== --- cfe/branches/release_90/test/OpenMP/parallel_copyin_codegen.cpp (original) +++ cfe/branches/release_90/test/OpenMP/parallel_copyin_codegen.cpp Mon Jul 22 10:45:30 2019 @@ -19,6 +19,7 @@ // RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DLAMBDA -triple x86_64-linux -emit-llvm %s -o - | FileCheck -check-prefix=TLS-LAMBDA %s // RUN: %clang_cc1 -verify -fopenmp -x c++ -fblocks -DBLOCKS -triple x86_64-linux -emit-llvm %s -o - | FileCheck -check-prefix=TLS-BLOCKS %s // RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DARRAY -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck -check-prefix=TLS-ARRAY %s +// RUN: %clang_cc1 -verify -fopenmp -x c++ -DNESTED -triple x86_64-linux -emit-llvm %s -o - | FileCheck %s -check-prefix=NESTED // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-linux -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-linux -emit-pch -o %t %s @@ -28,7 +29,7 @@ // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -std=c++11 -DARRAY -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s // SIMD-ONLY1-NOT: {{__kmpc|__tgt}} // expected-no-diagnostics -#ifndef ARRAY +#if !defined(ARRAY) && !defined(NESTED) #ifndef HEADER #define HEADER @@ -493,7 +494,7 @@ int main() { // TLS-CHECK: ret void #endif -#else +#elif defined(ARRAY) // ARRAY-LABEL: array_func // TLS-ARRAY-LABEL: array_func @@ -522,6 +523,24 @@ void array_func() { #pragma omp parallel copyin(a, s) ; } -#endif - +#elif defined(NESTED) +int t; +#pragma omp threadprivate(t) +// NESTED: foo +void foo() { + // NESTED: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED:@.+]] to void (i32*, i32*, ...)*)) +#pragma omp parallel +#pragma omp parallel copyin(t) + ++t; +} +// NESTED: define {{.*}}void [[OUTLINED]]( +// NESTED: [[T:%.+]] = call i32* [[THRP_T:@.+]]() +// NESTED: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.+}}, i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*)* [[OUTLINED1:@.+]] to void (i32*, i32*, ...)*), i32* [[T]]) + +// NESTED: define {{.*}}void [[OUTLINED1]]( +// NESTED: [[T_MASTER:%.+]] = load i32*, i32** % +// NESTED: [[T:%.+]] = call i32* [[THRP_T]]() +// NESTED: [[T_MASTER_VAL:%.+]] = load i32, i32* [[T_MASTER]], +// NESTED: store i32 [[T_MASTER_VAL]], i32* [[T]], +#endif // NESTED _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits