[OPENMP] Fixed DSA processing for predetermined shared variables.

This patch allows to use predetermined shared variables in private clauses in
parallel or tasks regions.

llvm-svn: 226549
This commit is contained in:
Alexey Bataev 2015-01-20 07:03:46 +00:00
parent 450a58b8af
commit 42971a3342
2 changed files with 18 additions and 6 deletions

View File

@ -425,16 +425,16 @@ DSAStackTy::DSAVarData DSAStackTy::getTopDSA(VarDecl *D, bool FromParent) {
// OpenMP [2.9.1.1, Data-sharing Attribute Rules for Variables Referenced
// in a Construct, C/C++, predetermined, p.4]
// Static data members are shared.
if (D->isStaticDataMember()) {
DVar.CKind = OMPC_shared;
return DVar;
}
// OpenMP [2.9.1.1, Data-sharing Attribute Rules for Variables Referenced
// in a Construct, C/C++, predetermined, p.7]
// Variables with static storage duration that are declared in a scope
// inside the construct are shared.
if (D->isStaticLocal()) {
if (D->isStaticDataMember() || D->isStaticLocal()) {
DSAVarData DVarTemp =
hasDSA(D, isOpenMPPrivate, MatchesAlways(), FromParent);
if (DVarTemp.CKind != OMPC_unknown && DVarTemp.RefExpr)
return DVar;
DVar.CKind = OMPC_shared;
return DVar;
}

View File

@ -44,6 +44,7 @@ S5 m(4); // expected-note 2 {{'m' defined here}}
template <class T, class C>
T tmain(T argc, C **argv) {
T i;
static T TA;
#pragma omp parallel
#pragma omp single copyprivate // expected-error {{expected '(' after 'copyprivate'}}
#pragma omp parallel
@ -95,12 +96,18 @@ T tmain(T argc, C **argv) {
#pragma omp parallel
#pragma omp single firstprivate(i) copyprivate(i) // expected-error {{firstprivate variable cannot be copyprivate}} expected-note {{defined as firstprivate}}
foo();
#pragma omp parallel private(TA)
{
#pragma omp single copyprivate(TA)
TA = 99;
}
return T();
}
int main(int argc, char **argv) {
int i;
static int intA;
#pragma omp parallel
#pragma omp single copyprivate // expected-error {{expected '(' after 'copyprivate'}}
#pragma omp parallel
@ -154,6 +161,11 @@ int main(int argc, char **argv) {
foo();
#pragma omp single copyprivate(i) nowait // expected-error {{the 'copyprivate' clause must not be used with the 'nowait' clause}} expected-note {{'nowait' clause is here}}
foo();
#pragma omp parallel private(intA)
{
#pragma omp single copyprivate(intA)
intA = 99;
}
return tmain(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<int, char>' requested here}}
}