Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down
10 changes: 6 additions & 4 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -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">,
Comment on lines +937 to +939
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be out of the scope of this change, but why isn't -fstack-arrays enabled with -O3?

If -fstack-arrays is not specified are array temporaries always allocated on the heap?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently mimicking gfortran (https://gcc.gnu.org/onlinedocs/gfortran/Code-Gen-Options.html), which runs it at Ofast.

We have not seen much benefits because Flang mostly allocates on the stack. @tblah is that right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we saw significant benefits on SNAP but not on SPEC2017 rate. I don't think we experimented with anything else.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks for the explanations.

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>,
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Driver/ToolChains/Flang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,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);
}
Expand Down
5 changes: 5 additions & 0 deletions flang/test/Driver/fast-math.f90
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading