r366483 - [OPENMP]Fix sharing of threadprivate variables with TLS support.
Hans Wennborg via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 22 10:45:04 PDT 2019
Merged to Clang 9 in r366706.
On Thu, Jul 18, 2019 at 12:39 PM Alexey Bataev via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
>
> Author: abataev
> Date: Thu Jul 18 12:40:24 2019
> New Revision: 366483
>
> URL: http://llvm.org/viewvc/llvm-project?rev=366483&view=rev
> Log:
> [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/trunk/lib/Sema/SemaOpenMP.cpp
> cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=366483&r1=366482&r2=366483&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Jul 18 12:40:24 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/trunk/test/OpenMP/parallel_copyin_codegen.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp?rev=366483&r1=366482&r2=366483&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp (original)
> +++ cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp Thu Jul 18 12:40:24 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
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list