diff options
author | Carlo Bertolli <cbertol@us.ibm.com> | 2016-03-18 21:43:32 +0000 |
---|---|---|
committer | Carlo Bertolli <cbertol@us.ibm.com> | 2016-03-18 21:43:32 +0000 |
commit | b74bfc80a434b645bddeb5865c28a3bdaa5440b8 (patch) | |
tree | c333045a0c346a158f42cda8032f1b3cf6d2e3f7 /clang/lib | |
parent | 9359b8fe5d944c8355ea49ba949d481fe080cec9 (diff) | |
download | bcm5719-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')
-rw-r--r-- | clang/lib/CodeGen/CGOpenMPRuntime.cpp | 1 | ||||
-rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 41 |
2 files changed, 42 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 5bf12e39c10..055a0949018 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -4175,6 +4175,7 @@ void CGOpenMPRuntime::emitTargetOutlinedFunction( // Emit target region as a standalone region. auto &&CodeGen = [&CS, &D](CodeGenFunction &CGF) { CodeGenFunction::OMPPrivateScope PrivateScope(CGF); + (void)CGF.EmitOMPFirstprivateClause(D, PrivateScope); CGF.EmitOMPPrivateClause(D, PrivateScope); (void)PrivateScope.Privatize(); 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); } |