Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC

Commits:

22 changed files:

Changes:

  • changelog.d/T27360
    1
    +section: compiler
    
    2
    +issues: #27360
    
    3
    +mrs: !16161
    
    4
    +synopsis:
    
    5
    +  Recognise ``considerAccessible`` under ticks (``-g``, ``-finfo-table-map``, ``-fhpc`` etc)
    
    6
    +description:
    
    7
    +  The pattern-match checker now properly recognises ``considerAccessible`` even
    
    8
    +  when it is surrounded by ticks (e.g. debug info ticks with ``-g``, with
    
    9
    +  ``-finfo-table-map``, etc). This ensures it works as advertised, suppressing
    
    10
    +  redundant pattern-match warnings, even when it occurs under a tick.

  • changelog.d/T27456
    1
    +section: base
    
    2
    +issues: #27456
    
    3
    +mrs: !16275
    
    4
    +synopsis:
    
    5
    +  Show `ExceptionContext` in `displayExceptionAnnotation` implementation of `WhileHandling`
    
    6
    +description:
    
    7
    +  In the past ``displayException`` (in terms of which ``WhileHandling``\'s ``displayExceptionAnnotation` is implemented) was changed to hide ``ExceptionContext``. This regressed the behavior of ``displayExceptionAnnotation`` from that which was originally specified. Restore the intended behavior of showing the ``ExceptionContext`` of the carried exception.
    
    8
    +

  • changelog.d/fix-use-std-ap-thunk
    1
    +section: codegen
    
    2
    +synopsis: Fix redundant AP thunk codegen when not using -ticky-ap-thunk
    
    3
    +issues: #27502
    
    4
    +mrs: !16340

  • compiler/GHC/Driver/Config/StgToCmm.hs
    ... ... @@ -87,7 +87,7 @@ initStgToCmmConfig dflags mod = StgToCmmConfig
    87 87
       , stgToCmmAvx           = isAvxEnabled                   dflags
    
    88 88
       , stgToCmmAvx2          = isAvx2Enabled                  dflags
    
    89 89
       , stgToCmmAvx512f       = isAvx512fEnabled               dflags
    
    90
    -  , stgToCmmTickyAP       = gopt Opt_Ticky_AP dflags
    
    90
    +  , stgToCmmUseStdApThunk = not $ gopt Opt_Ticky_AP dflags
    
    91 91
       -- See Note [Saving foreign call target to local]
    
    92 92
       , stgToCmmSaveFCallTargetToLocal = any (callerSaves platform) $ activeStgRegs platform
    
    93 93
       } where profile  = targetProfile dflags
    

  • compiler/GHC/Driver/Flags.hs
    ... ... @@ -379,6 +379,7 @@ impliedGFlags = [(Opt_DeferTypeErrors, turnOn, Opt_DeferTypedHoles)
    379 379
                     ,(Opt_ByteCodeAndObjectCode, turnOn, Opt_WriteByteCode)
    
    380 380
                     ,(Opt_InfoTableMap, turnOn, Opt_InfoTableMapWithStack)
    
    381 381
                     ,(Opt_InfoTableMap, turnOn, Opt_InfoTableMapWithFallback)
    
    382
    +                ,(Opt_InfoTableMap, turnOn, Opt_Ticky_AP)
    
    382 383
                     ] ++ validHoleFitsImpliedGFlags
    
    383 384
     
    
    384 385
     -- | General flags that are switched on/off when other general flags are switched
    

  • compiler/GHC/HsToCore/Pmc/Desugar.hs
    ... ... @@ -12,7 +12,8 @@ import GHC.Prelude
    12 12
     
    
    13 13
     import GHC.HsToCore.Pmc.Types
    
    14 14
     import GHC.HsToCore.Pmc.Utils
    
    15
    -import GHC.Core (Expr(Var,App))
    
    15
    +import GHC.Core (CoreExpr, Expr(Var,App))
    
    16
    +import GHC.Core.Utils (stripTicksTopE)
    
    16 17
     import GHC.Data.FastString (unpackFS, lengthFS, mkFastStringShortText)
    
    17 18
     import GHC.Driver.DynFlags
    
    18 19
     import GHC.Hs
    
    ... ... @@ -474,24 +475,28 @@ desugarLocalBinds _binds = return GdEnd
    474 475
     -- | Desugar a pattern guard
    
    475 476
     --   @pat <- e ==>  let x = e;  <guards for pat <- x>@
    
    476 477
     desugarBind :: LPat GhcTc -> LHsExpr GhcTc -> DsM GrdDag
    
    477
    -desugarBind p e = dsLExpr e >>= \case
    
    478
    -  Var y
    
    479
    -    | Nothing <- isDataConId_maybe y
    
    480
    -    -- RHS is a variable, so that will allow us to omit the let
    
    481
    -    -> desugarLPat y p
    
    482
    -  rhs -> do
    
    483
    -    (x, grds) <- desugarLPatV p
    
    484
    -    pure (PmLet x rhs `consGrdDag` grds)
    
    478
    +desugarBind p e =
    
    479
    +  dsLExpr_stripTicks e >>= \case
    
    480
    +    Var y
    
    481
    +      | Nothing <- isDataConId_maybe y
    
    482
    +      -- RHS is a variable, so that will allow us to omit the let
    
    483
    +      -> desugarLPat y p
    
    484
    +    rhs -> do
    
    485
    +      (x, grds) <- desugarLPatV p
    
    486
    +      pure (PmLet x rhs `consGrdDag` grds)
    
    485 487
     
    
    486 488
     -- | Desugar a boolean guard
    
    487 489
     --   @e ==>  let x = e; True <- x@
    
    488 490
     desugarBoolGuard :: LHsExpr GhcTc -> DsM GrdDag
    
    489 491
     desugarBoolGuard e
    
    490
    -  | isJust (isTrueLHsExpr e) = return GdEnd
    
    492
    +  | isJust (isTrueLHsExpr e) -- NB: looks through ticks
    
    491 493
         -- The formal thing to do would be to generate (True <- True)
    
    492 494
         -- but it is trivial to solve so instead we give back an empty
    
    493 495
         -- GrdDag for efficiency
    
    494
    -  | otherwise = dsLExpr e >>= \case
    
    496
    +  = return GdEnd
    
    497
    +
    
    498
    +  | otherwise
    
    499
    +  = dsLExpr_stripTicks e >>= \case
    
    495 500
           Var y
    
    496 501
             | Nothing <- isDataConId_maybe y
    
    497 502
             -- Omit the let by matching on y
    
    ... ... @@ -500,6 +505,19 @@ desugarBoolGuard e
    500 505
             x <- mkPmId boolTy
    
    501 506
             pure $ sequencePmGrds [PmLet x rhs, vanillaConGrd x trueDataCon []]
    
    502 507
     
    
    508
    +-- | Desugar an expression, stripping off top-level ticks from the resulting
    
    509
    +-- Core expression.
    
    510
    +--
    
    511
    +-- This function is used instead of 'dsLExpr' when we are immediately going to
    
    512
    +-- inspect the Core (as we do in e.g. 'desugarBoolGuard' or 'desugarBind') to
    
    513
    +-- make sure we properly look through intervening ticks (fixing #27360).
    
    514
    +--
    
    515
    +-- It's not needed when all we do is stash the resulting 'CoreExpr' into a
    
    516
    +-- 'GrdDag', as the rest of the machinery (such as 'GHC.HsToCore.Pmc.Solver.addCoreCt')
    
    517
    +-- looks through ticks.
    
    518
    +dsLExpr_stripTicks :: LHsExpr GhcTc -> DsM CoreExpr
    
    519
    +dsLExpr_stripTicks e = stripTicksTopE (const True) <$> dsLExpr e
    
    520
    +
    
    503 521
     {- Note [Field match order for RecCon]
    
    504 522
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    505 523
     The order for RecCon field patterns actually determines evaluation order of
    

  • compiler/GHC/StgToCmm/Bind.hs
    ... ... @@ -280,7 +280,7 @@ cgRhs id (StgRhsClosure fvs cc upd_flag args body _typ)
    280 280
       = do
    
    281 281
         profile <- getProfile
    
    282 282
         check_tags <- stgToCmmDoTagCheck <$> getStgToCmmConfig
    
    283
    -    use_std_ap_thunk <- stgToCmmTickyAP <$> getStgToCmmConfig
    
    283
    +    use_std_ap_thunk <- stgToCmmUseStdApThunk <$> getStgToCmmConfig
    
    284 284
         mkRhsClosure profile use_std_ap_thunk check_tags id cc (nonVoidIds (dVarSetElems fvs)) upd_flag args body
    
    285 285
     
    
    286 286
     ------------------------------------------------------------------------
    

  • compiler/GHC/StgToCmm/Config.hs
    ... ... @@ -73,7 +73,7 @@ data StgToCmmConfig = StgToCmmConfig
    73 73
       , stgToCmmAllowWordMul2Instr        :: !Bool   -- ^ Allowed to generate WordMul2 instruction
    
    74 74
       , stgToCmmAllowFMAInstr             :: FMASign -> Bool -- ^ Allowed to generate FMA instruction
    
    75 75
       , stgToCmmAllowIntWord64X2MinMax    :: !Bool   -- ^ Allowed to generate min/max instructions for Int64X2/Word64X2
    
    76
    -  , stgToCmmTickyAP                   :: !Bool   -- ^ Disable use of precomputed standard thunks.
    
    76
    +  , stgToCmmUseStdApThunk             :: !Bool   -- ^ Use precomputed standard AP thunks in the RTS.
    
    77 77
       , stgToCmmSaveFCallTargetToLocal    :: !Bool   -- ^ Save a foreign call target to a Cmm local, see
    
    78 78
                                                      -- Note [Saving foreign call target to local] for details
    
    79 79
       ------------------------------ SIMD flags ------------------------------------
    

  • libraries/base/changelog.md
    ... ... @@ -33,6 +33,7 @@
    33 33
       * Export `labelThread` from `Control.Concurrent`.([CLC proposal #376](https://github.com/haskell/core-libraries-committee/issues/376))
    
    34 34
       * Add a new module `System.IO.OS` with operations for obtaining operating-system handles (file descriptors, Windows handles). ([CLC proposal #369](https://github.com/haskell/core-libraries-committee/issues/369))
    
    35 35
       * Evaluate backtraces for "error" exceptions at the moment they are thrown. ([CLC proposal #383](https://github.com/haskell/core-libraries-committee/issues/383))
    
    36
    +  * Show `ExceptionContext` in `displayExceptionAnnotation` implementation of `WhileHandling` ([GHC #27456](https://gitlab.haskell.org/ghc/ghc/-/issues/27456))
    
    36 37
       * Hide implementation details when throwing exceptions in throw and throwSTM. ([CLC proposal #387](https://github.com/haskell/core-libraries-committee/issues/387))
    
    37 38
       * Change `hIsReadable` and `hIsWritable` such that they always throw a respective exception when encountering a closed or semi-closed handle, not just in the case of a file handle. ([CLC proposal #371](github.com/haskell/core-libraries-committee/issues/371))
    
    38 39
       * Annotate `onException` continuation with `WhileHandling`. ([CLC Proposal #397](https://github.com/haskell/core-libraries-committee/issues/397))
    

  • libraries/base/tests/T15349.stderr
    1
    -T15349: Uncaught exception ghc-internal:GHC.Internal.Control.Exception.Base.NonTermination:
    
    1
    +T15349.exe: Uncaught exception ghc-internal:GHC.Internal.Control.Exception.Base.NonTermination:
    
    2 2
     
    
    3 3
     <<loop>>
    
    4 4
     
    
    5
    -While handling thread blocked indefinitely in an MVar operation
    
    5
    +While handling ghc-internal:GHC.Internal.IO.Exception.BlockedIndefinitelyOnMVar:
    
    6
    +  |
    
    7
    +  | thread blocked indefinitely in an MVar operation
    
    6 8
     
    
    7 9
     HasCallStack backtrace:
    
    8
    -  throwIO, called at libraries/ghc-internal/src/GHC/Internal/Control/Monad/ST/Imp.hs:58:37 in ghc-internal:GHC.Internal.Control.Monad.ST.Imp
    
    10
    +  throwIO, called at libraries\ghc-internal\src\GHC\Internal\Control\Monad\ST\Imp.hs:59:37 in ghc-internal:GHC.Internal.Control.Monad.ST.Imp
    
    9 11
     

  • libraries/ghc-internal/src/GHC/Internal/Exception/Type.hs
    ... ... @@ -84,7 +84,7 @@ data WhileHandling = WhileHandling SomeException deriving Show
    84 84
     
    
    85 85
     instance ExceptionAnnotation WhileHandling where
    
    86 86
       displayExceptionAnnotation (WhileHandling e) =
    
    87
    -    "While handling " ++ case lines $ displayException e of
    
    87
    +    "While handling " ++ case lines $ displayExceptionWithInfo e of
    
    88 88
           [] -> ""
    
    89 89
           (l1:ls) ->
    
    90 90
             -- Indent lines forward.
    

  • libraries/ghc-internal/tests/backtraces/T14532b.stdout
    ... ... @@ -2,7 +2,14 @@ ghc-internal:GHC.Internal.Exception.ErrorCall:
    2 2
     
    
    3 3
     Error in Exception Handler
    
    4 4
     
    
    5
    -While handling Main Error
    
    5
    +While handling ghc-internal:GHC.Internal.Exception.ErrorCall:
    
    6
    +  |
    
    7
    +  | Main Error
    
    8
    +  |
    
    9
    +  | My custom Backtraces:
    
    10
    +  | HasCallStack backtrace:
    
    11
    +  |   throwIO, called at T14532b.hs:32:6 in main:Main
    
    12
    +  |
    
    6 13
     
    
    7 14
     My custom Backtraces:
    
    8 15
     HasCallStack backtrace:
    
    ... ... @@ -13,7 +20,14 @@ ghc-internal:GHC.Internal.Exception.ErrorCall:
    13 20
     
    
    14 21
     Error in Exception Handler
    
    15 22
     
    
    16
    -While handling Main Error
    
    23
    +While handling ghc-internal:GHC.Internal.Exception.ErrorCall:
    
    24
    +  |
    
    25
    +  | Main Error
    
    26
    +  |
    
    27
    +  | My custom Backtraces:
    
    28
    +  | HasCallStack backtrace:
    
    29
    +  |   error, called at T14532b.hs:41:6 in main:Main
    
    30
    +  |
    
    17 31
     
    
    18 32
     My custom Backtraces:
    
    19 33
     HasCallStack backtrace:
    

  • rts/Capability.c
    ... ... @@ -413,7 +413,7 @@ void initCapabilities (void)
    413 413
             max_n_capabilities = RtsFlags.ParFlags.nCapabilities;
    
    414 414
         }
    
    415 415
     
    
    416
    -    capabilities = stgMallocBytes(sizeof(Capability) * max_n_capabilities, "initCapabilities");
    
    416
    +    capabilities = stgMallocBytes(sizeof(Capability *) * max_n_capabilities, "initCapabilities");
    
    417 417
     
    
    418 418
         n_capabilities = 0;
    
    419 419
         moreCapabilities(0, RtsFlags.ParFlags.nCapabilities);
    
    ... ... @@ -422,7 +422,7 @@ void initCapabilities (void)
    422 422
     #else /* !THREADED_RTS */
    
    423 423
     
    
    424 424
         n_capabilities = 1;
    
    425
    -    capabilities = stgMallocBytes(sizeof(Capability), "initCapabilities");
    
    425
    +    capabilities = stgMallocBytes(sizeof(Capability *), "initCapabilities");
    
    426 426
         capabilities[0] = &MainCapability;
    
    427 427
     
    
    428 428
         initCapability(&MainCapability, 0);
    

  • rts/ContinuationOps.cmm
    ... ... @@ -108,7 +108,7 @@ stg_control0zh_ll // explicit stack
    108 108
       }
    
    109 109
     
    
    110 110
       W_ apply_mask_frame;
    
    111
    -  apply_mask_frame = StgContinuation_apply_mask_frame(cont);
    
    111
    +  apply_mask_frame = StgContinuation_apply_mask_frame(UNTAG(cont));
    
    112 112
     
    
    113 113
       // The stack has been updated, so it’s time to apply the input function,
    
    114 114
       // passing the captured continuation and a RealWorld token as arguments.
    

  • rts/PrimOps.cmm
    ... ... @@ -1565,7 +1565,10 @@ stg_readTVarIOzh ( P_ tvar /* :: TVar a */ )
    1565 1565
     
    
    1566 1566
     again:
    
    1567 1567
         result = %acquire StgTVar_current_value(tvar);
    
    1568
    -    resultinfo = %INFO_PTR(result);
    
    1568
    +    // when result is stg_TREC_HEADER_info, it's word aligned so UNTAG
    
    1569
    +    // is no-op; if it's a tagged closure we must UNTAG it to avoid an
    
    1570
    +    // unaligned memory access
    
    1571
    +    resultinfo = %INFO_PTR(UNTAG(result));
    
    1569 1572
         if (resultinfo == stg_TREC_HEADER_info) {
    
    1570 1573
             goto again;
    
    1571 1574
         }
    

  • testsuite/tests/codeGen/should_run/cgrun025.stderr
    1
    -"cgrun025"
    
    1
    +"cgrun025.exe"
    
    2 2
     ["cgrun025.hs"]
    
    3 3
     GOT PATH
    
    4 4
     {-# LANGUAGE ScopedTypeVariables #-}
    
    ... ... @@ -27,11 +27,16 @@ main = do
    27 27
         trace "hello, trace" $
    
    28 28
           catch (getEnv "__WURBLE__" >> return ()) (\ (e :: SomeException) -> error "hello, error")
    
    29 29
     hello, trace
    
    30
    -cgrun025: Uncaught exception ghc-internal:GHC.Internal.Exception.ErrorCall:
    
    30
    +cgrun025.exe: Uncaught exception ghc-internal:GHC.Internal.Exception.ErrorCall:
    
    31 31
     
    
    32 32
     hello, error
    
    33 33
     
    
    34
    -While handling __WURBLE__: getEnv: does not exist (no environment variable)
    
    34
    +While handling ghc-internal:GHC.Internal.IO.Exception.IOException:
    
    35
    +  |
    
    36
    +  | __WURBLE__: getEnv: does not exist (no environment variable)
    
    37
    +  |
    
    38
    +  | HasCallStack backtrace:
    
    39
    +  |   ioException, called at libraries\ghc-internal\src\GHC\Internal\System\Environment.hs:204:26 in ghc-internal:GHC.Internal.System.Environment
    
    35 40
     
    
    36 41
     HasCallStack backtrace:
    
    37 42
       error, called at cgrun025.hs:25:75 in main:Main
    

  • testsuite/tests/exceptions/T26759.stderr
    1
    -T26759: Uncaught exception ghc-internal:GHC.Internal.Exception.ErrorCall:
    
    1
    +T26759.exe: Uncaught exception ghc-internal:GHC.Internal.Exception.ErrorCall:
    
    2 2
     
    
    3 3
     cleanup failure
    
    4 4
     
    
    5
    -While handling outer failure
    
    5
    +While handling ghc-internal:GHC.Internal.Exception.ErrorCall:
    
    6
    +  |
    
    7
    +  | outer failure
    
    8
    +  |
    
    9
    +  | HasCallStack backtrace:
    
    10
    +  |   throwIO, called at T26759.hs:6:21 in main:Main
    
    6 11
     
    
    7 12
     HasCallStack backtrace:
    
    8 13
       throwIO, called at T26759.hs:7:22 in main:Main
    

  • testsuite/tests/ghc-e/should_fail/T18441fail7.stderr
    1
    -<interactive>: Uncaught exception ghc-9.13-inplace:GHC.Utils.Panic.GhcException:
    
    1
    +<interactive>: Uncaught exception ghc-10.1-inplace:GHC.Utils.Panic.GhcException:
    
    2 2
     
    
    3 3
     IO error:  "Abcde" does not exist
    
    4 4
     
    
    5
    -While handling IO error:  "Abcde" does not exist
    
    5
    +While handling ghc-10.1-inplace:GHC.Utils.Panic.GhcException:
    
    6
    +  |
    
    7
    +  | IO error:  "Abcde" does not exist
    
    6 8
     
    
    7 9
     HasCallStack backtrace:
    
    8
    -  throwIO, called at compiler/GHC/Utils/Error.hs:512:19 in ghc-9.13-inplace:GHC.Utils.Error
    
    10
    +  throwIO, called at compiler\GHC\Utils\Error.hs:499:19 in ghc-10.1-inplace:GHC.Utils.Error
    
    9 11
     
    
    10 12
     1

  • testsuite/tests/mdo/should_fail/mdofail006.stderr
    1
    -mdofail006: Uncaught exception ghc-internal:GHC.Internal.IO.Exception.FixIOException:
    
    1
    +mdofail006.exe: Uncaught exception ghc-internal:GHC.Internal.IO.Exception.FixIOException:
    
    2 2
     
    
    3 3
     cyclic evaluation in fixIO
    
    4 4
     
    
    5
    -While handling thread blocked indefinitely in an MVar operation
    
    5
    +While handling ghc-internal:GHC.Internal.IO.Exception.BlockedIndefinitelyOnMVar:
    
    6
    +  |
    
    7
    +  | thread blocked indefinitely in an MVar operation
    
    6 8
     
    
    7 9
     HasCallStack backtrace:
    
    8
    -  throwIO, called at libraries/ghc-internal/src/GHC/Internal/Control/Monad/Fix.hs:167:37 in ghc-internal:GHC.Internal.Control.Monad.Fix
    
    10
    +  throwIO, called at libraries\ghc-internal\src\GHC\Internal\Control\Monad\Fix.hs:169:37 in ghc-internal:GHC.Internal.Control.Monad.Fix
    
    9 11
     

  • testsuite/tests/pmcheck/should_compile/T27360.hs
    1
    +module T27360 where
    
    2
    +
    
    3
    +import GHC.Exts
    
    4
    +
    
    5
    +f :: ()
    
    6
    +f | False, considerAccessible = ()
    
    7
    +  | otherwise = ()
    
    8
    +
    
    9
    +g :: ()
    
    10
    +g | False, True <- considerAccessible = ()
    
    11
    +  | otherwise = ()

  • testsuite/tests/pmcheck/should_compile/all.T
    ... ... @@ -182,3 +182,4 @@ test('T24845', [], compile, [overlapping_incomplete])
    182 182
     test('T22652', [], compile, [overlapping_incomplete])
    
    183 183
     test('T22652a', [], compile, [overlapping_incomplete])
    
    184 184
     test('T24867', [], compile_fail, [overlapping_incomplete])
    
    185
    +test('T27360', normal, compile, [overlapping_incomplete + '-g3'])

  • testsuite/tests/runghc/T7859.stderr-mingw32
    ... ... @@ -2,7 +2,12 @@ runghc-9.13.20241015.exe: Uncaught exception ghc-internal:GHC.Internal.IO.Except
    2 2
     
    
    3 3
     defer-type-errors: rawSystem: does not exist (No such file or directory)
    
    4 4
     
    
    5
    -While handling rawSystem: does not exist (No such file or directory)
    
    5
    +While handling ghc-internal:GHC.Internal.IO.Exception.IOException:
    
    6
    +  |
    
    7
    +  | rawSystem: does not exist (No such file or directory)
    
    8
    +  |
    
    9
    +  | HasCallStack backtrace:
    
    10
    +  |   ioError, called at libraries/ghc-internal/src/GHC/Internal/Foreign/C/Error.hs:<line>:<column> in <package-id>:GHC.Internal.Foreign.C.Error
    
    6 11
     
    
    7 12
     HasCallStack backtrace:
    
    8 13
       ioError, called at libraries\process\System\Process\Common.hs:239:16 in process-1.6.25.0-inplace:System.Process.Common