Skip to content

Commit

Permalink
[OPENMP]Fix PR39366: do not try to private field if it is not captured.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alexey-bataev committed Oct 24, 2018
1 parent f377c18 commit 8d3394c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/Sema/SemaOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2181,8 +2181,14 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
// 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)) {
Expand Down
13 changes: 13 additions & 0 deletions test/OpenMP/task_codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8d3394c

Please sign in to comment.