diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2018-10-24 18:53:12 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2018-10-24 18:53:12 +0000 |
commit | 8d3394cba221c94f6732da891ac9a6e5f46b1a1b (patch) | |
tree | 681986023f492826d6284933733e12673aaacb50 | |
parent | f377c186fc4d7cd67698ab0c9e693bb195d3efe9 (diff) |
[OPENMP]Fix PR39366: do not try to private field if it is not captured.
The compiler is crashing if we trying to post-capture the fields
implicitly captured inside of the task constructs. Seems, this kind of
processing is not supported and such fields should not be
firstprivatized.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345177 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaOpenMP.cpp | 10 | ||||
-rw-r--r-- | test/OpenMP/task_codegen.cpp | 13 |
2 files changed, 21 insertions, 2 deletions
diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index d9f2973552..7b4cc9fd17 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -2181,8 +2181,14 @@ public: // Define implicit data-sharing attributes for task. DVar = Stack->getImplicitDSA(FD, /*FromParent=*/false); if (isOpenMPTaskingDirective(DKind) && DVar.CKind != OMPC_shared && - !Stack->isLoopControlVariable(FD).first) - ImplicitFirstprivate.push_back(E); + !Stack->isLoopControlVariable(FD).first) { + // Check if there is a captured expression for the current field in the + // region. Do not mark it as firstprivate unless there is no captured + // expression. + // TODO: try to make it firstprivate. + if (DVar.CKind != OMPC_unknown) + ImplicitFirstprivate.push_back(E); + } return; } if (isOpenMPTargetExecutionDirective(DKind)) { diff --git a/test/OpenMP/task_codegen.cpp b/test/OpenMP/task_codegen.cpp index fefe8b4329..05767726f0 100644 --- a/test/OpenMP/task_codegen.cpp +++ b/test/OpenMP/task_codegen.cpp @@ -278,5 +278,18 @@ int main() { // CHECK: load i32*, i32** % // CHECK: store i32 4, i32* % // CHECK: call i32 @__kmpc_omp_task(% + +struct S1 { + int a; + S1() { taskinit(); } + void taskinit() { +#pragma omp task + a = 0; + } +} s1; + +// CHECK-LABEL: taskinit +// CHECK: call i8* @__kmpc_omp_task_alloc( + #endif |