[flang-commits] [flang] 0f89e7a - [Flang][OpenMP] Show warning for -fdoconcurrent-to-openmp in SIMD only mode (#220943)

via flang-commits flang-commits at lists.llvm.org
Mon Sep 14 02:20:45 PDT 2026


Author: Sergio Afonso
Date: 2026-09-14T10:20:40+01:00
New Revision: 0f89e7a6027b9fc93032aa4d154028045ed9018f

URL: https://github.com/llvm/llvm-project/commit/0f89e7a6027b9fc93032aa4d154028045ed9018f
DIFF: https://github.com/llvm/llvm-project/commit/0f89e7a6027b9fc93032aa4d154028045ed9018f.diff

LOG: [Flang][OpenMP] Show warning for -fdoconcurrent-to-openmp in SIMD only mode (#220943)

The OpenMP feature is considered enabled if either `-fopenmp` or
`-fopenmp-simd` have been passed. However, full OpenMP support is
required in order for the `-fdoconcurrent-to-openmp` option to take
effect.

A warning message that wasn't shown when SIMD-only OpenMP support was
enabled is fixed.

Added: 
    

Modified: 
    flang/lib/Frontend/FrontendActions.cpp
    flang/test/Driver/do_concurrent_to_omp_cli.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 35c2b9ec881e8..da3c1de7e9903 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -323,7 +323,7 @@ bool CodeGenAction::beginSourceFileAction() {
       ci.getInvocation().getCodeGenOpts().getDoConcurrentMapping();
 
   if (opts.doConcurrentMappingKind != DoConcurrentMappingKind::DCMK_None &&
-      !isOpenMPEnabled) {
+      (!isOpenMPEnabled || opts.isSimdOnly)) {
     unsigned diagID = ci.getDiagnostics().getCustomDiagID(
         clang::DiagnosticsEngine::Warning,
         "OpenMP is required for lowering `do concurrent` loops to OpenMP."
@@ -343,7 +343,7 @@ bool CodeGenAction::beginSourceFileAction() {
   // WARNING: This pipeline must be run immediately after the lowering to
   // ensure that the FIR is correct with respect to OpenMP operations/
   // attributes.
-  if (isOpenMPEnabled || opts.isSimdOnly)
+  if (isOpenMPEnabled)
     fir::createOpenMPFIRPassPipeline(pm, opts);
 
   pm.enableVerifier(/*verifyPasses=*/true);

diff  --git a/flang/test/Driver/do_concurrent_to_omp_cli.f90 b/flang/test/Driver/do_concurrent_to_omp_cli.f90
index 723f148d2c371..9b6069649a031 100644
--- a/flang/test/Driver/do_concurrent_to_omp_cli.f90
+++ b/flang/test/Driver/do_concurrent_to_omp_cli.f90
@@ -13,6 +13,15 @@
 ! RUN: %flang -c -fdo-concurrent-to-openmp=host %s 2>&1 \
 ! RUN: | FileCheck %s --check-prefix=OPT
 
+! RUN: %flang -c -fno-openmp -fdo-concurrent-to-openmp=host %s 2>&1 \
+! RUN: | FileCheck %s --check-prefix=OPT
+
+! RUN: %flang -c -fopenmp-simd -fdo-concurrent-to-openmp=host %s 2>&1 \
+! RUN: | FileCheck %s --check-prefix=OPT
+
+! RUN: %flang -c -fno-openmp -fopenmp-simd -fdo-concurrent-to-openmp=host %s 2>&1 \
+! RUN: | FileCheck %s --check-prefix=OPT
+
 ! OPT: warning: OpenMP is required for lowering `do concurrent` loops to OpenMP.
 ! OPT-SAME:     Enable OpenMP using `-fopenmp`.
 


        


More information about the flang-commits mailing list