r270962 - [OPENMP] Fixed processing of '-fopenmp-version=' option and test.
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Thu May 26 21:13:40 PDT 2016
Author: abataev
Date: Thu May 26 23:13:39 2016
New Revision: 270962
URL: http://llvm.org/viewvc/llvm-project?rev=270962&view=rev
Log:
[OPENMP] Fixed processing of '-fopenmp-version=' option and test.
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/OpenMP/driver.c
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=270962&r1=270961&r2=270962&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu May 26 23:13:39 2016
@@ -4864,7 +4864,6 @@ void Clang::ConstructJob(Compilation &C,
// Forward flags for OpenMP
if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
options::OPT_fno_openmp, false)) {
- Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_version_EQ);
switch (getOpenMPRuntime(getToolChain(), Args)) {
case OMPRT_OMP:
case OMPRT_IOMP5:
@@ -4877,6 +4876,7 @@ void Clang::ConstructJob(Compilation &C,
if (!Args.hasFlag(options::OPT_fopenmp_use_tls,
options::OPT_fnoopenmp_use_tls, /*Default=*/true))
CmdArgs.push_back("-fnoopenmp-use-tls");
+ Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_version_EQ);
break;
default:
// By default, if Clang doesn't know how to generate useful OpenMP code
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=270962&r1=270961&r2=270962&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu May 26 23:13:39 2016
@@ -1954,15 +1954,16 @@ static void ParseLangArgs(LangOptions &O
}
// Check if -fopenmp is specified.
- Opts.OpenMP = Args.hasArg(options::OPT_fopenmp);
+ Opts.OpenMP = Args.hasArg(options::OPT_fopenmp) ? 1 : 0;
Opts.OpenMPUseTLS =
Opts.OpenMP && !Args.hasArg(options::OPT_fnoopenmp_use_tls);
Opts.OpenMPIsDevice =
Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_is_device);
if (Opts.OpenMP) {
- if (int Version = getLastArgIntValue(Args, OPT_fopenmp_version_EQ,
- Opts.OpenMP, Diags))
+ int Version =
+ getLastArgIntValue(Args, OPT_fopenmp_version_EQ, Opts.OpenMP, Diags);
+ if (Version != 0)
Opts.OpenMP = Version;
// Provide diagnostic when a given target is not expected to be an OpenMP
// device or host.
Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=270962&r1=270961&r2=270962&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Thu May 26 23:13:39 2016
@@ -922,24 +922,24 @@ static void InitializePredefinedMacros(c
}
// OpenMP definition
- if (LangOpts.OpenMP) {
- // OpenMP 2.2:
- // In implementations that support a preprocessor, the _OPENMP
- // macro name is defined to have the decimal value yyyymm where
- // yyyy and mm are the year and the month designations of the
- // version of the OpenMP API that the implementation support.
- switch (LangOpts.OpenMP) {
- case 40:
- Builder.defineMacro("_OPENMP", "201307");
- break;
- case 45:
- Builder.defineMacro("_OPENMP", "201511");
- break;
- default:
- // Default version is OpenMP 3.1
- Builder.defineMacro("_OPENMP", "201107");
- break;
- }
+ // OpenMP 2.2:
+ // In implementations that support a preprocessor, the _OPENMP
+ // macro name is defined to have the decimal value yyyymm where
+ // yyyy and mm are the year and the month designations of the
+ // version of the OpenMP API that the implementation support.
+ switch (LangOpts.OpenMP) {
+ case 0:
+ break;
+ case 40:
+ Builder.defineMacro("_OPENMP", "201307");
+ break;
+ case 45:
+ Builder.defineMacro("_OPENMP", "201511");
+ break;
+ default:
+ // Default version is OpenMP 3.1
+ Builder.defineMacro("_OPENMP", "201107");
+ break;
}
// CUDA device path compilaton
Modified: cfe/trunk/test/OpenMP/driver.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/driver.c?rev=270962&r1=270961&r2=270962&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/driver.c (original)
+++ cfe/trunk/test/OpenMP/driver.c Thu May 26 23:13:39 2016
@@ -8,17 +8,17 @@
// CHECK-NO-TLS: -cc1
// CHECK-NO-TLS-SAME: -fnoopenmp-use-tls
//
-// RUN: %clang %s -c -E -dM -fopenmp | FileCheck --check-prefix=CHECK-DEFAULT-VERSION %s
-// RUN: %clang %s -c -E -dM -fopenmp -fopenmp-version=1 | FileCheck --check-prefix=CHECK-DEFAULT-VERSION %s
-// RUN: %clang %s -c -E -dM -fopenmp -fopenmp-version=0 | FileCheck --check-prefix=CHECK-DEFAULT-VERSION %s
-// RUN: %clang %s -c -E -dM -fopenmp -fopenmp-version=100 | FileCheck --check-prefix=CHECK-DEFAULT-VERSION %s
-// RUN: %clang %s -c -E -dM -fopenmp -fopenmp-version=31 | FileCheck --check-prefix=CHECK-DEFAULT-VERSION %s
+// RUN: %clang %s -c -E -dM -fopenmp=libomp | FileCheck --check-prefix=CHECK-DEFAULT-VERSION %s
+// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=1 | FileCheck --check-prefix=CHECK-DEFAULT-VERSION %s
+// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=0 | FileCheck --check-prefix=CHECK-DEFAULT-VERSION %s
+// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=100 | FileCheck --check-prefix=CHECK-DEFAULT-VERSION %s
+// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=31 | FileCheck --check-prefix=CHECK-DEFAULT-VERSION %s
// CHECK-DEFAULT-VERSION: #define _OPENMP 201107
-// RUN: %clang %s -c -E -dM -fopenmp -fopenmp-version=40 | FileCheck --check-prefix=CHECK-40-VERSION %s
+// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=40 | FileCheck --check-prefix=CHECK-40-VERSION %s
// CHECK-40-VERSION: #define _OPENMP 201307
-// RUN: %clang %s -c -E -dM -fopenmp -fopenmp-version=45 | FileCheck --check-prefix=CHECK-45-VERSION %s
+// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 | FileCheck --check-prefix=CHECK-45-VERSION %s
// CHECK-45-VERSION: #define _OPENMP 201511
// RUN: %clang %s -c -E -dM -fopenmp-version=1 | FileCheck --check-prefix=CHECK-VERSION %s
More information about the cfe-commits
mailing list