Author: Tom Eccles
Date: 2025-04-02T10:43:48+01:00
New Revision: 9b2fd1a6ec935b2e31bb2b6fda82b7377b9bbf79

URL: 
https://github.com/llvm/llvm-project/commit/9b2fd1a6ec935b2e31bb2b6fda82b7377b9bbf79
DIFF: 
https://github.com/llvm/llvm-project/commit/9b2fd1a6ec935b2e31bb2b6fda82b7377b9bbf79.diff

LOG: [flang][OpenMP] Bump default OpenMP version to 3.1 (#133745)

Precise OpenMP standards support information is being documented in
#132707

Flang now has good support for OpenMP Version 3.1 and earlier.

Added: 
    

Modified: 
    clang/include/clang/Driver/Options.td
    flang/include/flang/Support/LangOptions.def
    flang/include/flang/Tools/CrossToolHelpers.h
    flang/lib/Frontend/CompilerInvocation.cpp
    flang/test/Driver/bbc-openmp-version-macro.f90
    flang/test/Driver/flang-openmp-version-macro.f90
    flang/test/Lower/OpenMP/rtl-flags.f90
    flang/tools/bbc/bbc.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 4c01088076818..534631e43d26d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3591,7 +3591,7 @@ def fopenmp_version_EQ : Joined<["-"], 
"fopenmp-version=">, Group<f_Group>,
   Flags<[NoArgumentUnused]>,
   Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
   HelpText<OpenMPVersionHelp<"Clang", "51">.str>,
-  HelpTextForVariants<[FlangOption, FC1Option], OpenMPVersionHelp<"Flang", 
"11">.str>;
+  HelpTextForVariants<[FlangOption, FC1Option], OpenMPVersionHelp<"Flang", 
"31">.str>;
 defm openmp_extensions: BoolFOption<"openmp-extensions",
   LangOpts<"OpenMPExtensions">, DefaultTrue,
   PosFlag<SetTrue, [NoArgumentUnused], [ClangOption, CC1Option],

diff  --git a/flang/include/flang/Support/LangOptions.def 
b/flang/include/flang/Support/LangOptions.def
index 1bfdba9cc2c1c..d5bf7a2ecc036 100644
--- a/flang/include/flang/Support/LangOptions.def
+++ b/flang/include/flang/Support/LangOptions.def
@@ -39,7 +39,7 @@ LANGOPT(AssociativeMath, 1, false)
 /// Allow division operations to be reassociated
 LANGOPT(ReciprocalMath, 1, false)
 /// Specify version of OpenMP standard
-LANGOPT(OpenMPVersion, 32, 0)
+LANGOPT(OpenMPVersion, 31, 0)
 /// Generate code only for OpenMP target device
 LANGOPT(OpenMPIsTargetDevice, 1, false)
 /// Generate OpenMP target code only for GPUs

diff  --git a/flang/include/flang/Tools/CrossToolHelpers.h 
b/flang/include/flang/Tools/CrossToolHelpers.h
index d9401e753fb79..1dbc18e2b348b 100644
--- a/flang/include/flang/Tools/CrossToolHelpers.h
+++ b/flang/include/flang/Tools/CrossToolHelpers.h
@@ -165,7 +165,7 @@ struct OffloadModuleOpts {
   bool OpenMPIsTargetDevice = false;
   bool OpenMPIsGPU = false;
   bool OpenMPForceUSM = false;
-  uint32_t OpenMPVersion = 11;
+  uint32_t OpenMPVersion = 31;
   std::string OMPHostIRFile = {};
   std::vector<llvm::Triple> OMPTargetTriples = {};
   bool NoGPULib = false;

diff  --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index 1ea7834746540..466d939b7b840 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -1108,8 +1108,8 @@ static bool parseOpenMPArgs(CompilerInvocation &res, 
llvm::opt::ArgList &args,
   unsigned numErrorsBefore = diags.getNumErrors();
   llvm::Triple t(res.getTargetOpts().triple);
 
-  // By default OpenMP is set to 1.1 version
-  res.getLangOpts().OpenMPVersion = 11;
+  // By default OpenMP is set to 3.1 version
+  res.getLangOpts().OpenMPVersion = 31;
   res.getFrontendOpts().features.Enable(
       Fortran::common::LanguageFeature::OpenMP);
   if (int Version = getLastArgIntValue(

diff  --git a/flang/test/Driver/bbc-openmp-version-macro.f90 
b/flang/test/Driver/bbc-openmp-version-macro.f90
index 7118021cba03a..6fa19e1672ad8 100644
--- a/flang/test/Driver/bbc-openmp-version-macro.f90
+++ b/flang/test/Driver/bbc-openmp-version-macro.f90
@@ -13,7 +13,7 @@
 ! RUN: bbc -fopenmp -fopenmp-version=51 -o - %s | FileCheck %s 
--check-prefix=OPENMP-VERSION-51
 ! RUN: bbc -fopenmp -fopenmp-version=52 -o - %s | FileCheck %s 
--check-prefix=OPENMP-VERSION-52
 
-! DEFAULT-OPENMP-VERSION: {{.*}} = arith.constant 199911 : i32
+! DEFAULT-OPENMP-VERSION: {{.*}} = arith.constant 201107 : i32
 ! OPENMP-VERSION-11: {{.*}} = arith.constant 199911 : i32
 ! OPENMP-VERSION-20: {{.*}} = arith.constant 200011 : i32
 ! OPENMP-VERSION-25: {{.*}} = arith.constant 200505 : i32

diff  --git a/flang/test/Driver/flang-openmp-version-macro.f90 
b/flang/test/Driver/flang-openmp-version-macro.f90
index 73cb322a06c00..95b3071544d06 100644
--- a/flang/test/Driver/flang-openmp-version-macro.f90
+++ b/flang/test/Driver/flang-openmp-version-macro.f90
@@ -13,7 +13,7 @@
 ! RUN: %flang_fc1 -fopenmp -fopenmp-version=51 -cpp -E %s | FileCheck %s 
--check-prefix=OPENMP-VERSION-51
 ! RUN: %flang_fc1 -fopenmp -fopenmp-version=52 -cpp -E %s | FileCheck %s 
--check-prefix=OPENMP-VERSION-52
 
-! DEFAULT-OPENMP-VERSION: integer :: var1 = 199911
+! DEFAULT-OPENMP-VERSION: integer :: var1 = 201107
 ! OPENMP-VERSION-11: integer :: var1 = 199911
 ! OPENMP-VERSION-20: integer :: var1 = 200011
 ! OPENMP-VERSION-25: integer :: var1 = 200505

diff  --git a/flang/test/Lower/OpenMP/rtl-flags.f90 
b/flang/test/Lower/OpenMP/rtl-flags.f90
index b38a6af0d7e3e..8b0db59264792 100644
--- a/flang/test/Lower/OpenMP/rtl-flags.f90
+++ b/flang/test/Lower/OpenMP/rtl-flags.f90
@@ -20,7 +20,7 @@
 !RUN: bbc -emit-hlfir -fopenmp -fopenmp-assume-no-nested-parallelism 
-fopenmp-is-target-device -o - %s | FileCheck %s 
--check-prefix=NEST-PAR-DEVICE-FIR
 !RUN: bbc -emit-hlfir -fopenmp -fopenmp-target-debug=1 
-fopenmp-assume-teams-oversubscription -fopenmp-assume-no-nested-parallelism 
-fopenmp-assume-threads-oversubscription -fopenmp-assume-no-thread-state 
-fopenmp-is-target-device -o - %s | FileCheck %s --check-prefix=ALL-DEVICE-FIR
 
-!DEFAULT-DEVICE-FIR: module attributes {{{.*}}omp.flags = 
#omp.flags<openmp_device_version = 11>
+!DEFAULT-DEVICE-FIR: module attributes {{{.*}}omp.flags = 
#omp.flags<openmp_device_version = 31>
 !DEFAULT-DEVICE-FIR-SAME: omp.is_target_device = true
 !DEFAULT-DEVICE-FIR-VERSION: module attributes {{{.*}}omp.flags = 
#omp.flags<openmp_device_version = 45>
 !DEFAULT-DEVICE-FIR-VERSION-SAME: omp.is_target_device = true
@@ -28,12 +28,12 @@
 !DEFAULT-HOST-FIR: module attributes {{{.*}}omp.is_target_device = false{{.*}}
 !DEFAULT-HOST-FIR-VERSION: module attributes {{{.*}}omp.is_target_device = 
false
 !DEFAULT-HOST-FIR-VERSION-SAME: omp.version = #omp.version<version = 45>
-!DBG-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<debug_kind = 
1, openmp_device_version = 11>
-!DBG-EQ-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<debug_kind 
= 111, openmp_device_version = 11>
-!TEAMS-OSUB-DEVICE-FIR: module attributes {{{.*}}omp.flags = 
#omp.flags<assume_teams_oversubscription = true, openmp_device_version = 11>
-!THREAD-OSUB-DEVICE-FIR: module attributes {{{.*}}omp.flags = 
#omp.flags<assume_threads_oversubscription = true, openmp_device_version = 11>
-!THREAD-STATE-DEVICE-FIR: module attributes {{{.*}}omp.flags = 
#omp.flags<assume_no_thread_state = true, openmp_device_version = 11>
-!NEST-PAR-DEVICE-FIR: module attributes {{{.*}}omp.flags = 
#omp.flags<assume_no_nested_parallelism = true, openmp_device_version = 11>
-!ALL-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<debug_kind = 
1, assume_teams_oversubscription = true, assume_threads_oversubscription = 
true, assume_no_thread_state = true, assume_no_nested_parallelism = true, 
openmp_device_version = 11>
+!DBG-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<debug_kind = 
1, openmp_device_version = 31>
+!DBG-EQ-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<debug_kind 
= 111, openmp_device_version = 31>
+!TEAMS-OSUB-DEVICE-FIR: module attributes {{{.*}}omp.flags = 
#omp.flags<assume_teams_oversubscription = true, openmp_device_version = 31>
+!THREAD-OSUB-DEVICE-FIR: module attributes {{{.*}}omp.flags = 
#omp.flags<assume_threads_oversubscription = true, openmp_device_version = 31>
+!THREAD-STATE-DEVICE-FIR: module attributes {{{.*}}omp.flags = 
#omp.flags<assume_no_thread_state = true, openmp_device_version = 31>
+!NEST-PAR-DEVICE-FIR: module attributes {{{.*}}omp.flags = 
#omp.flags<assume_no_nested_parallelism = true, openmp_device_version = 31>
+!ALL-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<debug_kind = 
1, assume_teams_oversubscription = true, assume_threads_oversubscription = 
true, assume_no_thread_state = true, assume_no_nested_parallelism = true, 
openmp_device_version = 31>
 subroutine omp_subroutine()
 end subroutine omp_subroutine

diff  --git a/flang/tools/bbc/bbc.cpp b/flang/tools/bbc/bbc.cpp
index c38e59f47c542..78ce510968ca5 100644
--- a/flang/tools/bbc/bbc.cpp
+++ b/flang/tools/bbc/bbc.cpp
@@ -169,7 +169,7 @@ static llvm::cl::list<std::string> targetTriplesOpenMP(
 static llvm::cl::opt<uint32_t>
     setOpenMPVersion("fopenmp-version",
                      llvm::cl::desc("OpenMP standard version"),
-                     llvm::cl::init(11));
+                     llvm::cl::init(31));
 
 static llvm::cl::opt<uint32_t> setOpenMPTargetDebug(
     "fopenmp-target-debug",


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to