[Git][ghc/ghc][wip/24462-quickfix] Disable `-fasm-shortcutting` on -O2 and warn about its usage.

Zubin (@wz1000) gitlab at gitlab.haskell.org
Thu Apr 11 08:03:28 UTC 2024



Zubin pushed to branch wip/24462-quickfix at Glasgow Haskell Compiler / GHC


Commits:
55a82c3c by Zubin Duggal at 2024-04-11T13:33:15+05:30
Disable `-fasm-shortcutting` on -O2 and warn about its usage.

This flag is known to result in unsound optimisations potentially resulting in
incorrect runtime behaviour (#24462).

- - - - -


5 changed files:

- compiler/GHC/Driver/Config/CmmToAsm.hs
- compiler/GHC/Driver/DynFlags.hs
- compiler/GHC/Driver/Session.hs
- docs/users_guide/bugs.rst
- docs/users_guide/using-optimisation.rst


Changes:

=====================================
compiler/GHC/Driver/Config/CmmToAsm.hs
=====================================
@@ -67,7 +67,8 @@ initNCGConfig dflags this_mod = NCGConfig
    , ncgDwarfSourceNotes    = osElfTarget (platformOS (targetPlatform dflags)) && debugLevel dflags > 2 -- We produce GHC-specific source-note DIEs only with -g3
    , ncgExposeInternalSymbols = gopt Opt_ExposeInternalSymbols dflags
    , ncgCmmStaticPred       = gopt Opt_CmmStaticPred dflags
-   , ncgEnableShortcutting  = gopt Opt_AsmShortcutting dflags
+                              -- Disabled due to https://gitlab.haskell.org/ghc/ghc/-/issues/24507
+   , ncgEnableShortcutting  = False -- gopt Opt_AsmShortcutting dflags
    , ncgComputeUnwinding    = debugLevel dflags > 0
    , ncgEnableDeadCodeElimination = not (gopt Opt_InfoTableMap dflags)
                                      -- Disable when -finfo-table-map is on (#20428)


=====================================
compiler/GHC/Driver/DynFlags.hs
=====================================
@@ -1263,7 +1263,8 @@ optLevelFlags -- see Note [Documenting optimisation flags]
     , ([1,2],   Opt_CaseMerge)
     , ([1,2],   Opt_CaseFolding)
     , ([1,2],   Opt_CmmElimCommonBlocks)
-    , ([2],     Opt_AsmShortcutting)
+    -- Disabled due to #24507
+    -- , ([2],     Opt_AsmShortcutting)
     , ([1,2],   Opt_CmmSink)
     , ([1,2],   Opt_CmmStaticPred)
     , ([1,2],   Opt_CSE)


=====================================
compiler/GHC/Driver/Session.hs
=====================================
@@ -2356,7 +2356,8 @@ fFlagsDeps = [
 -- See Note [Updating flag description in the User's Guide]
 -- See Note [Supporting CLI completion]
 -- Please keep the list of flags below sorted alphabetically
-  flagSpec "asm-shortcutting"                 Opt_AsmShortcutting,
+  depFlagSpec "asm-shortcutting"              Opt_AsmShortcutting
+    "this flag is disabled on this ghc version due to unsoundness concerns (https://gitlab.haskell.org/ghc/ghc/-/issues/24507)",
   flagGhciSpec "break-on-error"               Opt_BreakOnError,
   flagGhciSpec "break-on-exception"           Opt_BreakOnException,
   flagSpec "building-cabal-package"           Opt_BuildingCabalPackage,


=====================================
docs/users_guide/bugs.rst
=====================================
@@ -694,6 +694,9 @@ Bugs in GHC
 -  Because of a toolchain limitation we are unable to support full Unicode paths
    on Windows. On Windows we support up to Latin-1. See :ghc-ticket:`12971` for more.
 
+- ``-fasm-shortcutting`` may result in unsound optimisations and result in incorrect
+  runtime results. See :ghc-ticket:`24507` for more details.
+
 .. _bugs-ghci:
 
 Bugs in GHCi (the interactive GHC)


=====================================
docs/users_guide/using-optimisation.rst
=====================================
@@ -250,7 +250,7 @@ as such you shouldn't need to set any of them explicitly. A flag
     generator, merging basic blocks and avoiding jumps right after jumps.
 
 .. ghc-flag:: -fasm-shortcutting
-    :shortdesc: Enable shortcutting on assembly. Implied by :ghc-flag:`-O2`.
+    :shortdesc: Enable shortcutting on assembly.
     :type: dynamic
     :reverse: -fno-asm-shortcutting
     :category:
@@ -267,6 +267,9 @@ as such you shouldn't need to set any of them explicitly. A flag
     these. Note that due to platform limitations (:ghc-ticket:`21972`) this flag
     does nothing on macOS.
 
+    This flag is known to result in unsoundness in this version of GHC
+    (:ghc-ticket:`24507`).
+
 .. ghc-flag:: -fblock-layout-cfg
     :shortdesc: Use the new cfg based block layout algorithm. Implied by :ghc-flag:`-O`.
     :type: dynamic



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/55a82c3c80ab41d2cfbbe859a25c07219f501922

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/55a82c3c80ab41d2cfbbe859a25c07219f501922
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240411/82404d64/attachment-0001.html>


More information about the ghc-commits mailing list