Author: abataev Date: Thu Jul 11 13:35:31 2019 New Revision: 365821 URL: http://llvm.org/viewvc/llvm-project?rev=365821&view=rev Log: [OPENMP]Improve handling of analysis of unsupported VLAs in reductions.
Fixed the processing of the unsupported VLAs in the reduction clauses. Used targetDiag if the diagnostics can be delayed and emit it immediately if the target does not support VLAs and we're parsing target directive with the reduction clauses. Modified: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/test/OpenMP/target_vla_messages.cpp Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=365821&r1=365820&r2=365821&view=diff ============================================================================== --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Thu Jul 11 13:35:31 2019 @@ -9132,12 +9132,6 @@ public: } /// Return true inside OpenMP target region. bool isInOpenMPTargetExecutionDirective() const; - /// Return true if (un)supported features for the current target should be - /// diagnosed if OpenMP (offloading) is enabled. - bool shouldDiagnoseTargetSupportFromOpenMP() const { - return !getLangOpts().OpenMPIsDevice || isInOpenMPDeclareTargetContext() || - isInOpenMPTargetExecutionDirective(); - } /// Return the number of captured regions created for an OpenMP directive. static int getOpenMPCaptureLevels(OpenMPDirectiveKind Kind); Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=365821&r1=365820&r2=365821&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original) +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Jul 11 13:35:31 2019 @@ -12140,10 +12140,14 @@ static bool actOnOMPReductionKindClause( if ((OASE && !ConstantLengthOASE) || (!OASE && !ASE && D->getType().getNonReferenceType()->isVariablyModifiedType())) { - if (!Context.getTargetInfo().isVLASupported() && - S.shouldDiagnoseTargetSupportFromOpenMP()) { - S.Diag(ELoc, diag::err_omp_reduction_vla_unsupported) << !!OASE; - S.Diag(ELoc, diag::note_vla_unsupported); + if (!Context.getTargetInfo().isVLASupported()) { + if (isOpenMPTargetExecutionDirective(Stack->getCurrentDirective())) { + S.Diag(ELoc, diag::err_omp_reduction_vla_unsupported) << !!OASE; + S.Diag(ELoc, diag::note_vla_unsupported); + } else { + S.targetDiag(ELoc, diag::err_omp_reduction_vla_unsupported) << !!OASE; + S.targetDiag(ELoc, diag::note_vla_unsupported); + } continue; } // For arrays/array sections only: Modified: cfe/trunk/test/OpenMP/target_vla_messages.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_vla_messages.cpp?rev=365821&r1=365820&r2=365821&view=diff ============================================================================== --- cfe/trunk/test/OpenMP/target_vla_messages.cpp (original) +++ cfe/trunk/test/OpenMP/target_vla_messages.cpp Thu Jul 11 13:35:31 2019 @@ -206,4 +206,10 @@ void for_reduction(int arg) { #pragma omp parallel #pragma omp for reduction(+: vla[0:arg]) for (int i = 0; i < arg; i++) ; +#ifdef NO_VLA + // expected-error@+3 {{cannot generate code for reduction on array section, which requires a variable length array}} + // expected-note@+2 {{variable length arrays are not supported for the current target}} +#endif +#pragma omp target reduction(+ : vla[0:arg]) + for (int i = 0; i < arg; i++) ; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits