summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOpenMP.cpp
diff options
context:
space:
mode:
authorCarlo Bertolli <cbertol@us.ibm.com>2016-03-18 21:43:32 +0000
committerCarlo Bertolli <cbertol@us.ibm.com>2016-03-18 21:43:32 +0000
commitb74bfc80a434b645bddeb5865c28a3bdaa5440b8 (patch)
treec333045a0c346a158f42cda8032f1b3cf6d2e3f7 /clang/lib/Sema/SemaOpenMP.cpp
parent9359b8fe5d944c8355ea49ba949d481fe080cec9 (diff)
downloadbcm5719-llvm-b74bfc80a434b645bddeb5865c28a3bdaa5440b8.tar.gz
bcm5719-llvm-b74bfc80a434b645bddeb5865c28a3bdaa5440b8.zip
[OPENMP] Implementation of codegen for firstprivate clause of target directive
This patch implements the following aspects: It extends sema to check that a variable is not reference in both a map clause and firstprivate or private. This is needed to ensure correct functioning at codegen level, apart from being useful for the user. It implements firstprivate for target in codegen. The implementation applies to both host and nvptx devices. It adds regression tests for codegen of firstprivate, host and device side when using the host as device, and nvptx side. Please note that the regression test for nvptx codegen is missing VLAs. This is because VLAs currently require saving and restoring the stack which appears not to be a supported operation by nvptx backend. It adds a check in sema regression tests for target map, firstprivate, and private clauses. http://reviews.llvm.org/D18203 llvm-svn: 263837
Diffstat (limited to 'clang/lib/Sema/SemaOpenMP.cpp')
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 826f0690935..d58f91104fe 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -7225,6 +7225,20 @@ OMPClause *Sema::ActOnOpenMPPrivateClause(ArrayRef<Expr *> VarList,
continue;
}
+ // OpenMP 4.5 [2.15.5.1, Restrictions, p.3]
+ // A list item cannot appear in both a map clause and a data-sharing
+ // attribute clause on the same construct
+ if (DSAStack->getCurrentDirective() == OMPD_target) {
+ if(DSAStack->checkMapInfoForVar(VD, /* CurrentRegionOnly = */ true,
+ [&](Expr *RE) -> bool {return true;})) {
+ Diag(ELoc, diag::err_omp_variable_in_map_and_dsa)
+ << getOpenMPClauseName(OMPC_private)
+ << getOpenMPDirectiveName(DSAStack->getCurrentDirective());
+ ReportOriginalDSA(*this, DSAStack, D, DVar);
+ continue;
+ }
+ }
+
// OpenMP [2.9.3.3, Restrictions, C/C++, p.1]
// A variable of class type (or array thereof) that appears in a private
// clause requires an accessible, unambiguous default constructor for the
@@ -7456,6 +7470,19 @@ OMPClause *Sema::ActOnOpenMPFirstprivateClause(ArrayRef<Expr *> VarList,
continue;
}
}
+ // OpenMP 4.5 [2.15.5.1, Restrictions, p.3]
+ // A list item cannot appear in both a map clause and a data-sharing
+ // attribute clause on the same construct
+ if (CurrDir == OMPD_target) {
+ if(DSAStack->checkMapInfoForVar(VD, /* CurrentRegionOnly = */ true,
+ [&](Expr *RE) -> bool {return true;})) {
+ Diag(ELoc, diag::err_omp_variable_in_map_and_dsa)
+ << getOpenMPClauseName(OMPC_firstprivate)
+ << getOpenMPDirectiveName(DSAStack->getCurrentDirective());
+ ReportOriginalDSA(*this, DSAStack, D, DVar);
+ continue;
+ }
+ }
}
// Variably modified types are not supported for tasks.
@@ -9897,6 +9924,20 @@ Sema::ActOnOpenMPMapClause(OpenMPMapClauseKind MapTypeModifier,
continue;
}
+ // OpenMP 4.5 [2.15.5.1, Restrictions, p.3]
+ // A list item cannot appear in both a map clause and a data-sharing
+ // attribute clause on the same construct
+ if (DKind == OMPD_target && VD) {
+ auto DVar = DSAStack->getTopDSA(VD, false);
+ if (isOpenMPPrivate(DVar.CKind)) {
+ Diag(ELoc, diag::err_omp_variable_in_map_and_dsa)
+ << getOpenMPClauseName(DVar.CKind)
+ << getOpenMPDirectiveName(DSAStack->getCurrentDirective());
+ ReportOriginalDSA(*this, DSAStack, D, DVar);
+ continue;
+ }
+ }
+
Vars.push_back(RE);
DSAStack->addExprToVarMapInfo(D, RE);
}
OpenPOWER on IntegriCloud