r366474 - [OPENMP]Provide correct data sharing attributes for loop control
Hans Wennborg via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 22 10:41:47 PDT 2019
Merged to Clang 9 in r366705.
On Thu, Jul 18, 2019 at 10:48 AM Alexey Bataev via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
>
> Author: abataev
> Date: Thu Jul 18 10:49:13 2019
> New Revision: 366474
>
> URL: http://llvm.org/viewvc/llvm-project?rev=366474&view=rev
> Log:
> [OPENMP]Provide correct data sharing attributes for loop control
> variables.
>
> Loop control variables are private in loop-based constructs and we shall
> take this into account when generate the code for inner constructs.
> Currently, those variables are reported as shared in many cases. Moved
> the analysis of the data-sharing attributes of the loop control variable
> to an early semantic stage to correctly handle their attributes.
>
> Modified:
> cfe/trunk/lib/Sema/SemaOpenMP.cpp
> cfe/trunk/test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp
> cfe/trunk/test/OpenMP/distribute_parallel_for_simd_firstprivate_messages.cpp
> cfe/trunk/test/OpenMP/distribute_simd_firstprivate_messages.cpp
> cfe/trunk/test/OpenMP/distribute_simd_misc_messages.c
> cfe/trunk/test/OpenMP/for_misc_messages.c
> cfe/trunk/test/OpenMP/for_simd_misc_messages.c
> cfe/trunk/test/OpenMP/parallel_for_firstprivate_messages.cpp
> cfe/trunk/test/OpenMP/parallel_for_misc_messages.c
> cfe/trunk/test/OpenMP/parallel_for_simd_firstprivate_messages.cpp
> cfe/trunk/test/OpenMP/simd_misc_messages.c
> cfe/trunk/test/OpenMP/target_parallel_for_firstprivate_messages.cpp
> cfe/trunk/test/OpenMP/target_parallel_for_misc_messages.c
> cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp
> cfe/trunk/test/OpenMP/target_parallel_for_simd_misc_messages.c
> cfe/trunk/test/OpenMP/target_simd_firstprivate_messages.cpp
> cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_misc_messages.c
> cfe/trunk/test/OpenMP/target_teams_distribute_simd_misc_messages.c
> cfe/trunk/test/OpenMP/task_codegen.c
> cfe/trunk/test/OpenMP/taskloop_firstprivate_messages.cpp
> cfe/trunk/test/OpenMP/taskloop_simd_firstprivate_messages.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Jul 18 10:49:13 2019
> @@ -139,6 +139,7 @@ private:
> /// clause, false otherwise.
> llvm::Optional<std::pair<const Expr *, OMPOrderedClause *>> OrderedRegion;
> unsigned AssociatedLoops = 1;
> + bool HasMutipleLoops = false;
> const Decl *PossiblyLoopCounter = nullptr;
> bool NowaitRegion = false;
> bool CancelRegion = false;
> @@ -678,12 +679,19 @@ public:
> /// Set collapse value for the region.
> void setAssociatedLoops(unsigned Val) {
> getTopOfStack().AssociatedLoops = Val;
> + if (Val > 1)
> + getTopOfStack().HasMutipleLoops = true;
> }
> /// Return collapse value for region.
> unsigned getAssociatedLoops() const {
> const SharingMapTy *Top = getTopOfStackOrNull();
> return Top ? Top->AssociatedLoops : 0;
> }
> + /// Returns true if the construct is associated with multiple loops.
> + bool hasMutipleLoops() const {
> + const SharingMapTy *Top = getTopOfStackOrNull();
> + return Top ? Top->HasMutipleLoops : false;
> + }
>
> /// Marks current target region as one with closely nested teams
> /// region.
> @@ -5604,13 +5612,14 @@ void Sema::ActOnOpenMPLoopInitialization
> if (!ISC.checkAndSetInit(Init, /*EmitDiags=*/false)) {
> if (ValueDecl *D = ISC.getLoopDecl()) {
> auto *VD = dyn_cast<VarDecl>(D);
> + DeclRefExpr *PrivateRef = nullptr;
> if (!VD) {
> if (VarDecl *Private = isOpenMPCapturedDecl(D)) {
> VD = Private;
> } else {
> - DeclRefExpr *Ref = buildCapture(*this, D, ISC.getLoopDeclRefExpr(),
> - /*WithInit=*/false);
> - VD = cast<VarDecl>(Ref->getDecl());
> + PrivateRef = buildCapture(*this, D, ISC.getLoopDeclRefExpr(),
> + /*WithInit=*/false);
> + VD = cast<VarDecl>(PrivateRef->getDecl());
> }
> }
> DSAStack->addLoopControlVariable(D, VD);
> @@ -5623,6 +5632,49 @@ void Sema::ActOnOpenMPLoopInitialization
> Var->getType().getNonLValueExprType(Context),
> ForLoc, /*RefersToCapture=*/true));
> }
> + OpenMPDirectiveKind DKind = DSAStack->getCurrentDirective();
> + // OpenMP [2.14.1.1, Data-sharing Attribute Rules for Variables
> + // Referenced in a Construct, C/C++]. The loop iteration variable in the
> + // associated for-loop of a simd construct with just one associated
> + // for-loop may be listed in a linear clause with a constant-linear-step
> + // that is the increment of the associated for-loop. The loop iteration
> + // variable(s) in the associated for-loop(s) of a for or parallel for
> + // construct may be listed in a private or lastprivate clause.
> + DSAStackTy::DSAVarData DVar =
> + DSAStack->getTopDSA(D, /*FromParent=*/false);
> + // If LoopVarRefExpr is nullptr it means the corresponding loop variable
> + // is declared in the loop and it is predetermined as a private.
> + Expr *LoopDeclRefExpr = ISC.getLoopDeclRefExpr();
> + OpenMPClauseKind PredeterminedCKind =
> + isOpenMPSimdDirective(DKind)
> + ? (DSAStack->hasMutipleLoops() ? OMPC_lastprivate : OMPC_linear)
> + : OMPC_private;
> + if (((isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
> + DVar.CKind != PredeterminedCKind && DVar.RefExpr &&
> + (LangOpts.OpenMP <= 45 || (DVar.CKind != OMPC_lastprivate &&
> + DVar.CKind != OMPC_private))) ||
> + ((isOpenMPWorksharingDirective(DKind) || DKind == OMPD_taskloop ||
> + isOpenMPDistributeDirective(DKind)) &&
> + !isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
> + DVar.CKind != OMPC_private && DVar.CKind != OMPC_lastprivate)) &&
> + (DVar.CKind != OMPC_private || DVar.RefExpr)) {
> + Diag(Init->getBeginLoc(), diag::err_omp_loop_var_dsa)
> + << getOpenMPClauseName(DVar.CKind)
> + << getOpenMPDirectiveName(DKind)
> + << getOpenMPClauseName(PredeterminedCKind);
> + if (DVar.RefExpr == nullptr)
> + DVar.CKind = PredeterminedCKind;
> + reportOriginalDsa(*this, DSAStack, D, DVar,
> + /*IsLoopIterVar=*/true);
> + } else if (LoopDeclRefExpr) {
> + // Make the loop iteration variable private (for worksharing
> + // constructs), linear (for simd directives with the only one
> + // associated loop) or lastprivate (for simd directives with several
> + // collapsed or ordered loops).
> + if (DVar.CKind == OMPC_unknown)
> + DSAStack->addDSA(D, LoopDeclRefExpr, PredeterminedCKind,
> + PrivateRef);
> + }
> }
> }
> DSAStack->setAssociatedLoops(AssociatedLoops - 1);
> @@ -5677,8 +5729,6 @@ static bool checkOpenMPIterationSpace(
>
> // Check loop variable's type.
> if (ValueDecl *LCDecl = ISC.getLoopDecl()) {
> - Expr *LoopDeclRefExpr = ISC.getLoopDeclRefExpr();
> -
> // OpenMP [2.6, Canonical Loop Form]
> // Var is one of the following:
> // A variable of signed or unsigned integer type.
> @@ -5704,46 +5754,6 @@ static bool checkOpenMPIterationSpace(
> // sharing attributes.
> VarsWithImplicitDSA.erase(LCDecl);
>
> - // OpenMP [2.14.1.1, Data-sharing Attribute Rules for Variables Referenced
> - // in a Construct, C/C++].
> - // The loop iteration variable in the associated for-loop of a simd
> - // construct with just one associated for-loop may be listed in a linear
> - // clause with a constant-linear-step that is the increment of the
> - // associated for-loop.
> - // The loop iteration variable(s) in the associated for-loop(s) of a for or
> - // parallel for construct may be listed in a private or lastprivate clause.
> - DSAStackTy::DSAVarData DVar = DSA.getTopDSA(LCDecl, false);
> - // If LoopVarRefExpr is nullptr it means the corresponding loop variable is
> - // declared in the loop and it is predetermined as a private.
> - OpenMPClauseKind PredeterminedCKind =
> - isOpenMPSimdDirective(DKind)
> - ? ((NestedLoopCount == 1) ? OMPC_linear : OMPC_lastprivate)
> - : OMPC_private;
> - if (((isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
> - DVar.CKind != PredeterminedCKind && DVar.RefExpr &&
> - (SemaRef.getLangOpts().OpenMP <= 45 ||
> - (DVar.CKind != OMPC_lastprivate && DVar.CKind != OMPC_private))) ||
> - ((isOpenMPWorksharingDirective(DKind) || DKind == OMPD_taskloop ||
> - isOpenMPDistributeDirective(DKind)) &&
> - !isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
> - DVar.CKind != OMPC_private && DVar.CKind != OMPC_lastprivate)) &&
> - (DVar.CKind != OMPC_private || DVar.RefExpr)) {
> - SemaRef.Diag(Init->getBeginLoc(), diag::err_omp_loop_var_dsa)
> - << getOpenMPClauseName(DVar.CKind) << getOpenMPDirectiveName(DKind)
> - << getOpenMPClauseName(PredeterminedCKind);
> - if (DVar.RefExpr == nullptr)
> - DVar.CKind = PredeterminedCKind;
> - reportOriginalDsa(SemaRef, &DSA, LCDecl, DVar, /*IsLoopIterVar=*/true);
> - HasErrors = true;
> - } else if (LoopDeclRefExpr != nullptr) {
> - // Make the loop iteration variable private (for worksharing constructs),
> - // linear (for simd directives with the only one associated loop) or
> - // lastprivate (for simd directives with several collapsed or ordered
> - // loops).
> - if (DVar.CKind == OMPC_unknown)
> - DSA.addDSA(LCDecl, LoopDeclRefExpr, PredeterminedCKind);
> - }
> -
> assert(isOpenMPLoopDirective(DKind) && "DSA for non-loop vars");
>
> // Check test-expr.
>
> Modified: cfe/trunk/test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp (original)
> +++ cfe/trunk/test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp Thu Jul 18 10:49:13 2019
> @@ -162,14 +162,14 @@ int foomain(int argc, char **argv) {
> #pragma omp parallel private(i)
> #pragma omp target
> #pragma omp teams
> -#pragma omp distribute parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
> - for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp distribute parallel for' directive may not be firstprivate, predetermined as private}}
> +#pragma omp distribute parallel for firstprivate(i) // expected-note 2 {{defined as firstprivate}}
> + for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp distribute parallel for' directive may not be firstprivate, predetermined as private}}
> foo();
> #pragma omp parallel reduction(+ : i)
> #pragma omp target
> #pragma omp teams
> -#pragma omp distribute parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
> - for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp distribute parallel for' directive may not be firstprivate, predetermined as private}}
> +#pragma omp distribute parallel for firstprivate(i) // expected-note 2 {{defined as firstprivate}}
> + for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp distribute parallel for' directive may not be firstprivate, predetermined as private}}
> foo();
> return 0;
> }
>
> Modified: cfe/trunk/test/OpenMP/distribute_parallel_for_simd_firstprivate_messages.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_parallel_for_simd_firstprivate_messages.cpp?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/distribute_parallel_for_simd_firstprivate_messages.cpp (original)
> +++ cfe/trunk/test/OpenMP/distribute_parallel_for_simd_firstprivate_messages.cpp Thu Jul 18 10:49:13 2019
> @@ -162,14 +162,14 @@ int foomain(int argc, char **argv) {
> #pragma omp parallel private(i)
> #pragma omp target
> #pragma omp teams
> -#pragma omp distribute parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
> - for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp distribute parallel for simd' directive may not be firstprivate, predetermined as linear}}
> +#pragma omp distribute parallel for simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
> + for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp distribute parallel for simd' directive may not be firstprivate, predetermined as linear}}
> foo();
> #pragma omp parallel reduction(+ : i)
> #pragma omp target
> #pragma omp teams
> -#pragma omp distribute parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
> - for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp distribute parallel for simd' directive may not be firstprivate, predetermined as linear}}
> +#pragma omp distribute parallel for simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
> + for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp distribute parallel for simd' directive may not be firstprivate, predetermined as linear}}
> foo();
> return 0;
> }
>
> Modified: cfe/trunk/test/OpenMP/distribute_simd_firstprivate_messages.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_simd_firstprivate_messages.cpp?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/distribute_simd_firstprivate_messages.cpp (original)
> +++ cfe/trunk/test/OpenMP/distribute_simd_firstprivate_messages.cpp Thu Jul 18 10:49:13 2019
> @@ -162,14 +162,14 @@ int foomain(int argc, char **argv) {
> #pragma omp parallel private(i)
> #pragma omp target
> #pragma omp teams
> -#pragma omp distribute simd firstprivate(i) // expected-note {{defined as firstprivate}}
> - for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be firstprivate, predetermined as linear}}
> +#pragma omp distribute simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
> + for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be firstprivate, predetermined as linear}}
> foo();
> #pragma omp parallel reduction(+ : i)
> #pragma omp target
> #pragma omp teams
> -#pragma omp distribute simd firstprivate(i) // expected-note {{defined as firstprivate}}
> - for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be firstprivate, predetermined as linear}}
> +#pragma omp distribute simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
> + for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be firstprivate, predetermined as linear}}
> foo();
> return 0;
> }
>
> Modified: cfe/trunk/test/OpenMP/distribute_simd_misc_messages.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_simd_misc_messages.c?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/distribute_simd_misc_messages.c (original)
> +++ cfe/trunk/test/OpenMP/distribute_simd_misc_messages.c Thu Jul 18 10:49:13 2019
> @@ -487,11 +487,11 @@ void test_collapse() {
> #pragma omp distribute simd collapse(5 - 5)
> for (i = 0; i < 16; ++i)
> ;
> -// expected-note at +3 {{defined as reduction}}
> +// expected-note at +3 2 {{defined as reduction}}
> #pragma omp target
> #pragma omp teams
> #pragma omp distribute simd collapse(2) reduction(+ : i)
> - for (i = 0; i < 16; ++i)
> + for (i = 0; i < 16; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be reduction, predetermined as lastprivate}}
> // expected-note at +1 {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for' directive into a parallel or another task region?}}
> for (int j = 0; j < 16; ++j)
> // expected-error at +2 2 {{reduction variable must be shared}}
>
> Modified: cfe/trunk/test/OpenMP/for_misc_messages.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_misc_messages.c?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/for_misc_messages.c (original)
> +++ cfe/trunk/test/OpenMP/for_misc_messages.c Thu Jul 18 10:49:13 2019
> @@ -214,10 +214,10 @@ void test_collapse() {
> ;
> #pragma omp parallel
> #pragma omp for collapse(2)
> - for (i = 0; i < 16; ++i)
> + for (i = 0; i < 16; ++i) // expected-note {{defined as private}}
> // expected-note at +1 {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for' directive into a parallel or another task region?}}
> for (int j = 0; j < 16; ++j)
> -// expected-error at +2 {{reduction variable must be shared}}
> +// expected-error at +2 2 {{reduction variable must be shared}}
> // expected-error at +1 {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
> #pragma omp for reduction(+ : i, j)
> for (int k = 0; k < 16; ++k)
>
> Modified: cfe/trunk/test/OpenMP/for_simd_misc_messages.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_simd_misc_messages.c?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/for_simd_misc_messages.c (original)
> +++ cfe/trunk/test/OpenMP/for_simd_misc_messages.c Thu Jul 18 10:49:13 2019
> @@ -381,10 +381,10 @@ void test_collapse() {
> ;
> #pragma omp parallel
> #pragma omp for simd collapse(2)
> - for (i = 0; i < 16; ++i)
> + for (i = 0; i < 16; ++i) // expected-note {{defined as lastprivate}}
> // expected-note at +1 {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for simd' directive into a parallel or another task region?}}
> for (int j = 0; j < 16; ++j)
> -// expected-error at +2 {{reduction variable must be shared}}
> +// expected-error at +2 2 {{reduction variable must be shared}}
> // expected-error at +1 {{OpenMP constructs may not be nested inside a simd region}}
> #pragma omp for simd reduction(+ : i, j)
> for (int k = 0; k < 16; ++k)
>
> Modified: cfe/trunk/test/OpenMP/parallel_for_firstprivate_messages.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_firstprivate_messages.cpp?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/parallel_for_firstprivate_messages.cpp (original)
> +++ cfe/trunk/test/OpenMP/parallel_for_firstprivate_messages.cpp Thu Jul 18 10:49:13 2019
> @@ -127,12 +127,12 @@ int foomain(int argc, char **argv) {
> for (i = 0; i < argc; ++i)
> foo();
> #pragma omp parallel private(i)
> -#pragma omp parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
> - for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}}
> +#pragma omp parallel for firstprivate(i) // expected-note 2 {{defined as firstprivate}}
> + for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}}
> foo();
> #pragma omp parallel reduction(+ : i)
> -#pragma omp parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
> - for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}}
> +#pragma omp parallel for firstprivate(i) // expected-note 2 {{defined as firstprivate}}
> + for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}}
> foo();
> return 0;
> }
>
> Modified: cfe/trunk/test/OpenMP/parallel_for_misc_messages.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_misc_messages.c?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/parallel_for_misc_messages.c (original)
> +++ cfe/trunk/test/OpenMP/parallel_for_misc_messages.c Thu Jul 18 10:49:13 2019
> @@ -162,9 +162,9 @@ void test_collapse() {
> #pragma omp parallel for collapse(5 - 5)
> for (i = 0; i < 16; ++i)
> ;
> -// expected-note at +1 {{defined as firstprivate}}
> +// expected-note at +1 2 {{defined as firstprivate}}
> #pragma omp parallel for collapse(2) firstprivate(i)
> - for (i = 0; i < 16; ++i)
> + for (i = 0; i < 16; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}}
> // expected-note at +1 {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for' directive into a parallel or another task region?}}
> for (int j = 0; j < 16; ++j)
> // expected-error at +2 2 {{reduction variable must be shared}}
>
> Modified: cfe/trunk/test/OpenMP/parallel_for_simd_firstprivate_messages.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_simd_firstprivate_messages.cpp?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/parallel_for_simd_firstprivate_messages.cpp (original)
> +++ cfe/trunk/test/OpenMP/parallel_for_simd_firstprivate_messages.cpp Thu Jul 18 10:49:13 2019
> @@ -129,12 +129,12 @@ int foomain(int argc, char **argv) {
> for (i = 0; i < argc; ++i)
> foo();
> #pragma omp parallel private(i)
> -#pragma omp parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
> - for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be firstprivate, predetermined as linear}}
> +#pragma omp parallel for simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
> + for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be firstprivate, predetermined as linear}}
> foo();
> #pragma omp parallel reduction(+ : i)
> -#pragma omp parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
> - for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be firstprivate, predetermined as linear}}
> +#pragma omp parallel for simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
> + for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be firstprivate, predetermined as linear}}
> foo();
> return 0;
> }
>
> Modified: cfe/trunk/test/OpenMP/simd_misc_messages.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/simd_misc_messages.c?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/simd_misc_messages.c (original)
> +++ cfe/trunk/test/OpenMP/simd_misc_messages.c Thu Jul 18 10:49:13 2019
> @@ -359,10 +359,10 @@ void test_collapse() {
> #pragma omp simd collapse(5 - 5)
> for (i = 0; i < 16; ++i)
> ;
> -// expected-note at +2 {{defined as reduction}}
> +// expected-note at +2 2 {{defined as reduction}}
> #pragma omp parallel
> #pragma omp simd collapse(2) reduction(+ : i)
> - for (i = 0; i < 16; ++i)
> + for (i = 0; i < 16; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp simd' directive may not be reduction, predetermined as lastprivate}}
> // expected-note at +1 {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for' directive into a parallel or another task region?}}
> for (int j = 0; j < 16; ++j)
> // expected-error at +2 2 {{reduction variable must be shared}}
>
> Modified: cfe/trunk/test/OpenMP/target_parallel_for_firstprivate_messages.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_for_firstprivate_messages.cpp?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/target_parallel_for_firstprivate_messages.cpp (original)
> +++ cfe/trunk/test/OpenMP/target_parallel_for_firstprivate_messages.cpp Thu Jul 18 10:49:13 2019
> @@ -136,12 +136,12 @@ int foomain(int argc, char **argv) {
> for (i = 0; i < argc; ++i)
> foo();
> #pragma omp parallel private(i)
> -#pragma omp target parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
> - for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target parallel for' directive may not be firstprivate, predetermined as private}}
> +#pragma omp target parallel for firstprivate(i) // expected-note 2 {{defined as firstprivate}}
> + for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp target parallel for' directive may not be firstprivate, predetermined as private}}
> foo();
> #pragma omp parallel reduction(+ : i)
> -#pragma omp target parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
> - for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target parallel for' directive may not be firstprivate, predetermined as private}}
> +#pragma omp target parallel for firstprivate(i) // expected-note 2 {{defined as firstprivate}}
> + for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp target parallel for' directive may not be firstprivate, predetermined as private}}
> foo();
> return 0;
> }
>
> Modified: cfe/trunk/test/OpenMP/target_parallel_for_misc_messages.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_for_misc_messages.c?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/target_parallel_for_misc_messages.c (original)
> +++ cfe/trunk/test/OpenMP/target_parallel_for_misc_messages.c Thu Jul 18 10:49:13 2019
> @@ -162,9 +162,9 @@ void test_collapse() {
> #pragma omp target parallel for collapse(5 - 5)
> for (i = 0; i < 16; ++i)
> ;
> -// expected-note at +1 {{defined as firstprivate}}
> +// expected-note at +1 2 {{defined as firstprivate}}
> #pragma omp target parallel for collapse(2) firstprivate(i)
> - for (i = 0; i < 16; ++i)
> + for (i = 0; i < 16; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target parallel for' directive may not be firstprivate, predetermined as private}}
> // expected-note at +1 {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for' directive into a parallel or another task region?}}
> for (int j = 0; j < 16; ++j)
> // expected-error at +2 2 {{reduction variable must be shared}}
>
> Modified: cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp (original)
> +++ cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp Thu Jul 18 10:49:13 2019
> @@ -136,12 +136,12 @@ int foomain(int argc, char **argv) {
> for (i = 0; i < argc; ++i)
> foo();
> #pragma omp parallel private(i)
> -#pragma omp target parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
> - for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be firstprivate, predetermined as linear}}
> +#pragma omp target parallel for simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
> + for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be firstprivate, predetermined as linear}}
> foo();
> #pragma omp parallel reduction(+ : i)
> -#pragma omp target parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
> - for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be firstprivate, predetermined as linear}}
> +#pragma omp target parallel for simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
> + for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be firstprivate, predetermined as linear}}
> foo();
> return 0;
> }
>
> Modified: cfe/trunk/test/OpenMP/target_parallel_for_simd_misc_messages.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_for_simd_misc_messages.c?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/target_parallel_for_simd_misc_messages.c (original)
> +++ cfe/trunk/test/OpenMP/target_parallel_for_simd_misc_messages.c Thu Jul 18 10:49:13 2019
> @@ -163,8 +163,8 @@ void test_collapse() {
> for (i = 0; i < 16; ++i)
> ;
> // expected-note at +1 {{defined as firstprivate}}
> -#pragma omp target parallel for simd collapse(2) firstprivate(i)
> - for (i = 0; i < 16; ++i)
> +#pragma omp target parallel for simd collapse(2) firstprivate(i) // expected-note {{defined as firstprivate}}
> + for (i = 0; i < 16; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be firstprivate, predetermined as lastprivate}}
> // expected-note at +1 {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for' directive into a parallel or another task region?}}
> for (int j = 0; j < 16; ++j)
> // expected-error at +2 2 {{reduction variable must be shared}}
>
> Modified: cfe/trunk/test/OpenMP/target_simd_firstprivate_messages.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_simd_firstprivate_messages.cpp?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/target_simd_firstprivate_messages.cpp (original)
> +++ cfe/trunk/test/OpenMP/target_simd_firstprivate_messages.cpp Thu Jul 18 10:49:13 2019
> @@ -136,12 +136,12 @@ int foomain(int argc, char **argv) {
> for (i = 0; i < argc; ++i)
> foo();
> #pragma omp parallel private(i)
> -#pragma omp target simd firstprivate(i) // expected-note {{defined as firstprivate}}
> - for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target simd' directive may not be firstprivate, predetermined as linear}}
> +#pragma omp target simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
> + for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp target simd' directive may not be firstprivate, predetermined as linear}}
> foo();
> #pragma omp parallel reduction(+ : i)
> -#pragma omp target simd firstprivate(i) // expected-note {{defined as firstprivate}}
> - for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target simd' directive may not be firstprivate, predetermined as linear}}
> +#pragma omp target simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
> + for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp target simd' directive may not be firstprivate, predetermined as linear}}
> foo();
> return 0;
> }
>
> Modified: cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_misc_messages.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_misc_messages.c?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_misc_messages.c (original)
> +++ cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_misc_messages.c Thu Jul 18 10:49:13 2019
> @@ -164,8 +164,8 @@ void test_collapse() {
> ;
>
> // expected-error at +4 {{OpenMP constructs may not be nested inside a simd region}}
> -#pragma omp target teams distribute parallel for simd collapse(2) firstprivate(i)
> - for (i = 0; i < 16; ++i)
> +#pragma omp target teams distribute parallel for simd collapse(2) firstprivate(i) // expected-note {{defined as firstprivate}}
> + for (i = 0; i < 16; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target teams distribute parallel for simd' directive may not be firstprivate, predetermined as lastprivate}}
> for (int j = 0; j < 16; ++j)
> #pragma omp parallel for reduction(+ : i, j)
> for (int k = 0; k < 16; ++k)
>
> Modified: cfe/trunk/test/OpenMP/target_teams_distribute_simd_misc_messages.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_simd_misc_messages.c?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/target_teams_distribute_simd_misc_messages.c (original)
> +++ cfe/trunk/test/OpenMP/target_teams_distribute_simd_misc_messages.c Thu Jul 18 10:49:13 2019
> @@ -164,8 +164,8 @@ void test_collapse() {
> ;
>
> // expected-error at +4 {{OpenMP constructs may not be nested inside a simd region}}
> -#pragma omp target teams distribute simd collapse(2) firstprivate(i)
> - for (i = 0; i < 16; ++i)
> +#pragma omp target teams distribute simd collapse(2) firstprivate(i) // expected-note {{defined as firstprivate}}
> + for (i = 0; i < 16; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target teams distribute simd' directive may not be firstprivate, predetermined as lastprivate}}
> for (int j = 0; j < 16; ++j)
> #pragma omp parallel for reduction(+ : i, j)
> for (int k = 0; k < 16; ++k)
>
> Modified: cfe/trunk/test/OpenMP/task_codegen.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/task_codegen.c?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/task_codegen.c (original)
> +++ cfe/trunk/test/OpenMP/task_codegen.c Thu Jul 18 10:49:13 2019
> @@ -32,4 +32,19 @@ int main() {
> // CHECK: call i8* @__kmpc_omp_task_alloc(
> // CHECK: call i32 @__kmpc_omp_task(
> // CHECK: call void @__kmpc_end_taskgroup(
> +
> +// CHECK-LINE: @bar
> +void bar() {
> + // CHECK: call void @__kmpc_for_static_init_4(
> +#pragma omp for
> +for (int i = 0; i < 10; ++i)
> + // CHECK: [[BUF:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* @{{.+}}, i32 %{{.+}}, i32 1, i64 48,
> + // CHECK: [[BC_BUF:%.+]] = bitcast i8* [[BUF]] to [[TT_WITH_PRIVS:%.+]]*
> + // CHECK: [[PRIVS:%.+]] = getelementptr inbounds [[TT_WITH_PRIVS]], [[TT_WITH_PRIVS]]* [[BC_BUF]], i32 0, i32 1
> + // CHECK: [[I_PRIV:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}} [[PRIVS]], i32 0, i32 0
> + // CHECK: store i32 %{{.+}}, i32* [[I_PRIV]],
> + // CHECK: = call i32 @__kmpc_omp_task(%struct.ident_t* @{{.+}}, i32 %{{.+}}, i8* [[BUF]])
> +#pragma omp task
> +++i;
> +}
> #endif
>
> Modified: cfe/trunk/test/OpenMP/taskloop_firstprivate_messages.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_firstprivate_messages.cpp?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/taskloop_firstprivate_messages.cpp (original)
> +++ cfe/trunk/test/OpenMP/taskloop_firstprivate_messages.cpp Thu Jul 18 10:49:13 2019
> @@ -150,11 +150,11 @@ int foomain(int argc, char **argv) {
> for (i = 0; i < argc; ++i)
> foo();
> #pragma omp parallel private(i)
> -#pragma omp taskloop firstprivate(i) // expected-note {{defined as firstprivate}}
> - for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp taskloop' directive may not be firstprivate, predetermined as private}}
> +#pragma omp taskloop firstprivate(i) // expected-note 2 {{defined as firstprivate}}
> + for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp taskloop' directive may not be firstprivate, predetermined as private}}
> foo();
> -#pragma omp parallel reduction(+ : i)
> -#pragma omp taskloop firstprivate(i) // expected-note {{defined as firstprivate}}
> +#pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
> +#pragma omp taskloop firstprivate(i) // expected-note {{defined as firstprivate}} expected-error {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}}
> for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp taskloop' directive may not be firstprivate, predetermined as private}}
> foo();
> return 0;
>
> Modified: cfe/trunk/test/OpenMP/taskloop_simd_firstprivate_messages.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_simd_firstprivate_messages.cpp?rev=366474&r1=366473&r2=366474&view=diff
> ==============================================================================
> --- cfe/trunk/test/OpenMP/taskloop_simd_firstprivate_messages.cpp (original)
> +++ cfe/trunk/test/OpenMP/taskloop_simd_firstprivate_messages.cpp Thu Jul 18 10:49:13 2019
> @@ -150,11 +150,11 @@ int foomain(int argc, char **argv) {
> for (i = 0; i < argc; ++i)
> foo();
> #pragma omp parallel private(i)
> -#pragma omp taskloop simd firstprivate(i) // expected-note {{defined as firstprivate}}
> - for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp taskloop simd' directive may not be firstprivate, predetermined as linear}}
> +#pragma omp taskloop simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
> + for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp taskloop simd' directive may not be firstprivate, predetermined as linear}}
> foo();
> -#pragma omp parallel reduction(+ : i)
> -#pragma omp taskloop simd firstprivate(i) // expected-note {{defined as firstprivate}}
> +#pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
> +#pragma omp taskloop simd firstprivate(i) // expected-note {{defined as firstprivate}} expected-error {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}}
> for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp taskloop simd' directive may not be firstprivate, predetermined as linear}}
> foo();
> return 0;
> @@ -307,9 +307,9 @@ int main(int argc, char **argv) {
> #pragma omp taskloop simd firstprivate(i) // expected-note {{defined as firstprivate}}
> for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp taskloop simd' directive may not be firstprivate, predetermined as linear}}
> foo();
> -#pragma omp parallel reduction(+ : i) // expected-note 2 {{defined as reduction}}
> +#pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
> #pragma omp taskloop simd firstprivate(i) // expected-error {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}}
> - for (i = 0; i < argc; ++i) // expected-error {{reduction variables may not be accessed in an explicit task}}
> + for (i = 0; i < argc; ++i)
> foo();
> #pragma omp taskloop simd firstprivate(i) //expected-note {{defined as firstprivate}}
> for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp taskloop simd' directive may not be firstprivate, predetermined as linear}}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list