Skip to content

Commit 9bb3c62

Browse files
[Flang][Driver] Deprecate Ofast (llvm#101701)
This is subject to agreement by the Flang community (https://discourse.llvm.org/t/rfc-deprecate-ofast-in-flang/80243).
1 parent 625e0a4 commit 9bb3c62

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,10 @@ def warn_drv_deprecated_arg_ofast : Warning<
452452
"argument '-Ofast' is deprecated; use '-O3 -ffast-math' for the same behavior,"
453453
" or '-O3' to enable only conforming optimizations">,
454454
InGroup<DeprecatedOFast>;
455+
def warn_drv_deprecated_arg_ofast_for_flang : Warning<
456+
"argument '-Ofast' is deprecated; use '-O3 -ffast-math -fstack-arrays' for the same behavior,"
457+
" or '-O3 -fstack-arrays' to enable only conforming optimizations">,
458+
InGroup<DeprecatedOFast>;
455459
def warn_drv_deprecated_custom : Warning<
456460
"argument '%0' is deprecated, %1">, InGroup<Deprecated>;
457461
def warn_drv_assuming_mfloat_abi_is : Warning<

clang/include/clang/Driver/Options.td

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -933,10 +933,12 @@ def O : Joined<["-"], "O">, Group<O_Group>,
933933
def O_flag : Flag<["-"], "O">, Visibility<[ClangOption, CC1Option, FC1Option]>,
934934
Alias<O>, AliasArgs<["1"]>;
935935
def Ofast : Joined<["-"], "Ofast">, Group<O_Group>,
936-
Visibility<[ClangOption, CC1Option, FlangOption]>,
937-
HelpTextForVariants<[ClangOption, CC1Option],
938-
"Deprecated; use '-O3 -ffast-math' for the same behavior,"
939-
" or '-O3' to enable only conforming optimizations">;
936+
Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
937+
HelpTextForVariants<[FlangOption, FC1Option],
938+
"Deprecated; use '-O3 -ffast-math -fstack-arrays' for the same behavior,"
939+
" or '-O3 -fstack-arrays' to enable only conforming optimizations">,
940+
HelpText<"Deprecated; use '-O3 -ffast-math' for the same behavior,"
941+
" or '-O3' to enable only conforming optimizations">;
940942
def P : Flag<["-"], "P">,
941943
Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
942944
Group<Preprocessor_Group>,

clang/lib/Driver/ToolChains/Flang.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,7 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA,
937937
D.Diag(diag::warn_O4_is_O3);
938938
} else if (A->getOption().matches(options::OPT_Ofast)) {
939939
CmdArgs.push_back("-O3");
940+
D.Diag(diag::warn_drv_deprecated_arg_ofast_for_flang);
940941
} else {
941942
A->render(Args, CmdArgs);
942943
}

flang/test/Driver/fast-math.f90

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
! Test for correct forwarding of fast-math flags from the compiler driver to the
22
! frontend driver
33

4+
! Check warning message for Ofast deprecation
5+
! RUN: %flang -Ofast -### %s -o %t 2>&1 | FileCheck %s
6+
! CHECK: warning: argument '-Ofast' is deprecated; use '-O3 -ffast-math -fstack-arrays' for the same behavior, or '-O3
7+
! -fstack-arrays' to enable only conforming optimizations [-Wdeprecated-ofast]
8+
49
! -Ofast => -ffast-math -O3 -fstack-arrays
510
! RUN: %flang -Ofast -fsyntax-only -### %s -o %t 2>&1 \
611
! RUN: | FileCheck --check-prefix=CHECK-OFAST %s

0 commit comments

Comments
 (0)