Skip to content

release/19.x: Ofast deprecation clarifications (#101005) #101663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2024

Conversation

llvmbot
Copy link
Member

@llvmbot llvmbot commented Aug 2, 2024

Backport 48d4d4b

Requested by: @AaronBallman

Following up on the RFC discussion, this is clarifying that the main
purpose and effect of the -Ofast deprecation is to discourage its usage
and that everything else is more or less open for discussion, e.g. there
is no timeline yet for removal.

---------

Co-authored-by: Aaron Ballman <[email protected]>
(cherry picked from commit 48d4d4b)
@llvmbot llvmbot added this to the LLVM 19.X Release milestone Aug 2, 2024
@llvmbot
Copy link
Member Author

llvmbot commented Aug 2, 2024

@AaronBallman What do you think about merging this PR to the release branch?

@llvmbot llvmbot requested a review from AaronBallman August 2, 2024 12:40
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Aug 2, 2024
@llvmbot
Copy link
Member Author

llvmbot commented Aug 2, 2024

@llvm/pr-subscribers-clang

Author: None (llvmbot)

Changes

Backport 48d4d4b

Requested by: @AaronBallman


Full diff: https://github.com/llvm/llvm-project/pull/101663.diff

1 Files Affected:

  • (modified) clang/docs/CommandGuide/clang.rst (+6-2)
diff --git a/clang/docs/CommandGuide/clang.rst b/clang/docs/CommandGuide/clang.rst
index 663aca1f6ddcb..a0c2594d06c61 100644
--- a/clang/docs/CommandGuide/clang.rst
+++ b/clang/docs/CommandGuide/clang.rst
@@ -429,8 +429,12 @@ Code Generation Options
 
     :option:`-Ofast` Enables all the optimizations from :option:`-O3` along
     with other aggressive optimizations that may violate strict compliance with
-    language standards. This is deprecated in favor of :option:`-O3`
-    in combination with :option:`-ffast-math`.
+    language standards. This is deprecated in Clang 19 and a warning is emitted
+    that :option:`-O3` in combination with :option:`-ffast-math` should be used
+    instead if the request for non-standard math behavior is intended. There
+    is no timeline yet for removal; the aim is to discourage use of
+    :option:`-Ofast` due to the surprising behavior of an optimization flag
+    changing the observable behavior of correct code.
 
     :option:`-Os` Like :option:`-O2` with extra optimizations to reduce code
     size.

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

LGTM! There's no chance these changes are what is breaking the ABI precommit CI tests. ;-)

@tru tru merged commit 9ac3941 into llvm:release/19.x Aug 2, 2024
12 of 16 checks passed
Copy link

github-actions bot commented Aug 2, 2024

@AaronBallman (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR.

@AaronBallman
Copy link
Collaborator

The current release note reads as:

- The ``-Ofast`` command-line option has been deprecated. This option both
  enables the ``-O3`` optimization-level, as well as enabling non-standard
  ``-ffast-math`` behaviors. As such, it is somewhat misleading as an
  "optimization level". Users are advised to switch to ``-O3 -ffast-math`` if
  the use of non-standard math behavior is intended, and ``-O3`` otherwise.
  See `RFC <https://discourse.llvm.org/t/rfc-deprecate-ofast/78687>`_ for details.

and I think we'd like this to be changed to instead read:

- The ``-Ofast`` command-line option has been deprecated. This option both
  enables the ``-O3`` optimization-level, as well as enabling other
  options, including non-standard ``-ffast-math`` behaviors. As such, 
  it is somewhat misleading as an "optimization level". Users are
  advised to switch to ``-O3 -ffast-math -fstrict-aliasing``
  to retain the previous behavior, and ``-O3`` otherwise.
  **Note**: there is no firm date for removal of the option; its
  use is discouraged and the option may or may not be removed
  in the future. See
  `RFC <https://discourse.llvm.org/t/rfc-deprecate-ofast/78687>`_
  for details.

WDYT @sjoerdmeijer ?

Copy link
Collaborator

@sjoerdmeijer sjoerdmeijer left a comment

Choose a reason for hiding this comment

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

Excellent, thanks, LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category release:note
Projects
Development

Successfully merging this pull request may close these issues.

4 participants