Skip to content

Commit b33ae61

Browse files
[Flang][Driver] Deprecate Ofast
1 parent c8bbbaa commit b33ae61

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
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: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,10 +933,13 @@ 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]>,
936+
Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
937937
HelpTextForVariants<[ClangOption, CC1Option],
938938
"Deprecated; use '-O3 -ffast-math' for the same behavior,"
939-
" or '-O3' to enable only conforming optimizations">;
939+
" or '-O3' to enable only conforming optimizations">,
940+
HelpTextForVariants<[FlangOption, FC1Option],
941+
"Deprecated; use '-O3 -ffast-math -fstack-arrays' for the same behavior,"
942+
" or '-O3 -fstack-arrays' to enable only conforming optimizations">;
940943
def P : Flag<["-"], "P">,
941944
Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
942945
Group<Preprocessor_Group>,

clang/lib/Driver/ToolChains/Flang.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,7 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA,
934934
D.Diag(diag::warn_O4_is_O3);
935935
} else if (A->getOption().matches(options::OPT_Ofast)) {
936936
CmdArgs.push_back("-O3");
937+
D.Diag(diag::warn_drv_deprecated_arg_ofast_for_flang);
937938
} else {
938939
A->render(Args, CmdArgs);
939940
}

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)