[flang-commits] [flang] 9bb3c62 - [Flang][Driver] Deprecate Ofast (#101701)
via flang-commits
flang-commits at lists.llvm.org
Fri Jan 24 02:18:19 PST 2025
Author: Kiran Chandramohan
Date: 2025-01-24T10:18:14Z
New Revision: 9bb3c62948d0c6dd3fb233186ae6a79744012b8f
URL: https://github.com/llvm/llvm-project/commit/9bb3c62948d0c6dd3fb233186ae6a79744012b8f
DIFF: https://github.com/llvm/llvm-project/commit/9bb3c62948d0c6dd3fb233186ae6a79744012b8f.diff
LOG: [Flang][Driver] Deprecate Ofast (#101701)
This is subject to agreement by the Flang community
(https://discourse.llvm.org/t/rfc-deprecate-ofast-in-flang/80243).
Added:
Modified:
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/test/Driver/fast-math.f90
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 612f7e330ba51e..288786b8ce9399 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -452,6 +452,10 @@ def warn_drv_deprecated_arg_ofast : Warning<
"argument '-Ofast' is deprecated; use '-O3 -ffast-math' for the same behavior,"
" or '-O3' to enable only conforming optimizations">,
InGroup<DeprecatedOFast>;
+def warn_drv_deprecated_arg_ofast_for_flang : Warning<
+ "argument '-Ofast' is deprecated; use '-O3 -ffast-math -fstack-arrays' for the same behavior,"
+ " or '-O3 -fstack-arrays' to enable only conforming optimizations">,
+ InGroup<DeprecatedOFast>;
def warn_drv_deprecated_custom : Warning<
"argument '%0' is deprecated, %1">, InGroup<Deprecated>;
def warn_drv_assuming_mfloat_abi_is : Warning<
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index df705104d9ea31..c5b7fcb7c7f09b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -933,10 +933,12 @@ def O : Joined<["-"], "O">, Group<O_Group>,
def O_flag : Flag<["-"], "O">, Visibility<[ClangOption, CC1Option, FC1Option]>,
Alias<O>, AliasArgs<["1"]>;
def Ofast : Joined<["-"], "Ofast">, Group<O_Group>,
- Visibility<[ClangOption, CC1Option, FlangOption]>,
- HelpTextForVariants<[ClangOption, CC1Option],
- "Deprecated; use '-O3 -ffast-math' for the same behavior,"
- " or '-O3' to enable only conforming optimizations">;
+ Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
+ HelpTextForVariants<[FlangOption, FC1Option],
+ "Deprecated; use '-O3 -ffast-math -fstack-arrays' for the same behavior,"
+ " or '-O3 -fstack-arrays' to enable only conforming optimizations">,
+ HelpText<"Deprecated; use '-O3 -ffast-math' for the same behavior,"
+ " or '-O3' to enable only conforming optimizations">;
def P : Flag<["-"], "P">,
Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
Group<Preprocessor_Group>,
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 9c1fd28a3a8a26..45d05ed3e24853 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -937,6 +937,7 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA,
D.Diag(diag::warn_O4_is_O3);
} else if (A->getOption().matches(options::OPT_Ofast)) {
CmdArgs.push_back("-O3");
+ D.Diag(diag::warn_drv_deprecated_arg_ofast_for_flang);
} else {
A->render(Args, CmdArgs);
}
diff --git a/flang/test/Driver/fast-math.f90 b/flang/test/Driver/fast-math.f90
index 47175488b98bcc..e677432bc04fae 100644
--- a/flang/test/Driver/fast-math.f90
+++ b/flang/test/Driver/fast-math.f90
@@ -1,6 +1,11 @@
! Test for correct forwarding of fast-math flags from the compiler driver to the
! frontend driver
+! Check warning message for Ofast deprecation
+! RUN: %flang -Ofast -### %s -o %t 2>&1 | FileCheck %s
+! CHECK: warning: argument '-Ofast' is deprecated; use '-O3 -ffast-math -fstack-arrays' for the same behavior, or '-O3
+! -fstack-arrays' to enable only conforming optimizations [-Wdeprecated-ofast]
+
! -Ofast => -ffast-math -O3 -fstack-arrays
! RUN: %flang -Ofast -fsyntax-only -### %s -o %t 2>&1 \
! RUN: | FileCheck --check-prefix=CHECK-OFAST %s
More information about the flang-commits
mailing list