Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

7 changed files:

Changes:

  • compiler/GHC/Core/Lint.hs
    ... ... @@ -26,6 +26,7 @@ module GHC.Core.Lint (
    26 26
         -- ** Debug output
    
    27 27
         EndPassConfig (..),
    
    28 28
         endPassIO,
    
    29
    +    lintMessage,
    
    29 30
         displayLintResults, dumpPassResult
    
    30 31
      ) where
    
    31 32
     
    
    ... ... @@ -309,11 +310,6 @@ path does not result in allocation in the hot path. This can be surprisingly
    309 310
     impactful. Changing `lint_app` reduced allocations for one test program I was
    
    310 311
     looking at by ~4%.
    
    311 312
     
    
    312
    -Note [MCInfo for Lint]
    
    313
    -~~~~~~~~~~~~~~~~~~~~~~
    
    314
    -When printing a Lint message, use the MCInfo severity so that the
    
    315
    -message is printed on stderr rather than stdout (#13342).
    
    316
    -
    
    317 313
     ************************************************************************
    
    318 314
     *                                                                      *
    
    319 315
                      Beginning and ending passes
    
    ... ... @@ -321,6 +317,12 @@ message is printed on stderr rather than stdout (#13342).
    321 317
     ************************************************************************
    
    322 318
     -}
    
    323 319
     
    
    320
    +lintMessage :: Logger -> SDoc -> IO ()
    
    321
    +lintMessage logger =
    
    322
    +  -- Note: Use logInfo when printing a Lint message, so that the message is
    
    323
    +  -- printed on stderr rather than stdout (#13342).
    
    324
    +  logInfo logger . withPprStyle defaultDumpStyle
    
    325
    +
    
    324 326
     -- | Configuration for boilerplate operations at the end of a
    
    325 327
     -- compilation pass producing Core.
    
    326 328
     data EndPassConfig = EndPassConfig
    
    ... ... @@ -436,8 +438,7 @@ displayLintResults :: Logger
    436 438
                        -> IO ()
    
    437 439
     displayLintResults logger display_warnings pp_what pp_pgm (warns, errs)
    
    438 440
       | not (isEmptyBag errs)
    
    439
    -  = do { logMsg logger Err.MCInfo noSrcSpan  -- See Note [MCInfo for Lint]
    
    440
    -           $ withPprStyle defaultDumpStyle
    
    441
    +  = do { lintMessage logger
    
    441 442
                (vcat [ lint_banner "errors" pp_what, Err.pprMessageBag errs
    
    442 443
                      , text "*** Offending Program ***"
    
    443 444
                      , pp_pgm
    
    ... ... @@ -447,8 +448,7 @@ displayLintResults logger display_warnings pp_what pp_pgm (warns, errs)
    447 448
       | not (isEmptyBag warns)
    
    448 449
       , log_enable_debug (logFlags logger)
    
    449 450
       , display_warnings
    
    450
    -  = logMsg logger Err.MCInfo noSrcSpan  -- See Note [MCInfo for Lint]
    
    451
    -      $ withPprStyle defaultDumpStyle
    
    451
    +  = lintMessage logger
    
    452 452
             (lint_banner "warnings" pp_what $$ Err.pprMessageBag (mapBag ($$ blankLine) warns))
    
    453 453
     
    
    454 454
       | otherwise = return ()
    

  • compiler/GHC/Driver/CodeOutput.hs
    ... ... @@ -18,6 +18,7 @@ import GHC.Prelude
    18 18
     import GHC.Platform
    
    19 19
     import GHC.ForeignSrcLang
    
    20 20
     import GHC.Data.FastString
    
    21
    +import GHC.Core.Lint ( lintMessage )
    
    21 22
     
    
    22 23
     import GHC.CmmToAsm     ( nativeCodeGen )
    
    23 24
     import GHC.CmmToLlvm    ( llvmCodeGen )
    
    ... ... @@ -55,7 +56,6 @@ import GHC.Utils.Panic.Plain ( pgmError )
    55 56
     import GHC.Unit
    
    56 57
     import GHC.Unit.Finder      ( mkStubPaths )
    
    57 58
     
    
    58
    -import GHC.Types.SrcLoc
    
    59 59
     import GHC.Types.CostCentre
    
    60 60
     import GHC.Types.ForeignStubs
    
    61 61
     import GHC.Types.Unique.DSM
    
    ... ... @@ -109,10 +109,7 @@ codeOutput logger tmpfs llvm_config dflags unit_state this_mod filenm location g
    109 109
                       (text "CmmLint"<+>brackets (ppr this_mod))
    
    110 110
                       (const ()) $ do
    
    111 111
                     { case cmmLint (targetPlatform dflags) cmm of
    
    112
    -                        Just err -> do { logMsg logger
    
    113
    -                                                   MCInfo -- See Note [MCInfo for Lint] in "GHC.Core.Lint"
    
    114
    -                                                   noSrcSpan
    
    115
    -                                                   $ withPprStyle defaultDumpStyle err
    
    112
    +                        Just err -> do { lintMessage logger err
    
    116 113
                                            ; ghcExit logger 1
    
    117 114
                                            }
    
    118 115
                             Nothing  -> return ()
    

  • compiler/GHC/Driver/Pipeline/Execute.hs
    ... ... @@ -1162,7 +1162,7 @@ getHCFilePackages filename =
    1162 1162
     linkDynLibCheck :: Logger -> TmpFs -> DynFlags -> UnitEnv -> [String] -> [UnitId] -> IO ()
    
    1163 1163
     linkDynLibCheck logger tmpfs dflags unit_env o_files dep_units = do
    
    1164 1164
       when (haveRtsOptsFlags dflags) $
    
    1165
    -    logMsg logger MCInfo noSrcSpan
    
    1165
    +    logInfo logger
    
    1166 1166
           $ withPprStyle defaultUserStyle
    
    1167 1167
           (text "Warning: -rtsopts and -with-rtsopts have no effect with -shared." $$
    
    1168 1168
           text "    Call hs_init_ghc() from your main() function to set these options.")
    

  • compiler/GHC/Iface/Load.hs
    ... ... @@ -1104,7 +1104,7 @@ For some background on this choice see #15269.
    1104 1104
     showIface :: Logger -> DynFlags -> UnitState -> NameCache -> FilePath -> IO ()
    
    1105 1105
     showIface logger dflags unit_state name_cache filename = do
    
    1106 1106
        let profile = targetProfile dflags
    
    1107
    -       printer = logMsg logger MCOutput noSrcSpan . withPprStyle defaultDumpStyle
    
    1107
    +       printer = logOutput logger . withPprStyle defaultDumpStyle
    
    1108 1108
     
    
    1109 1109
        -- skip the hi way check; we don't want to worry about profiled vs.
    
    1110 1110
        -- non-profiled interfaces, for example.
    

  • compiler/GHC/Linker/Loader.hs
    ... ... @@ -508,7 +508,7 @@ classifyLdInput logger platform f
    508 508
       | isObjectFilename platform f = return (Just (Objects [f]))
    
    509 509
       | isDynLibFilename platform f = return (Just (DLLPath f))
    
    510 510
       | otherwise          = do
    
    511
    -        logMsg logger MCInfo noSrcSpan
    
    511
    +        logInfo logger
    
    512 512
                 $ withPprStyle defaultUserStyle
    
    513 513
                 (text ("Warning: ignoring unrecognised input `" ++ f ++ "'"))
    
    514 514
             return Nothing
    

  • compiler/GHC/Stg/Lint.hs
    ... ... @@ -104,6 +104,7 @@ import GHC.Stg.Utils
    104 104
     import GHC.Core.DataCon
    
    105 105
     import GHC.Core             ( AltCon(..) )
    
    106 106
     import GHC.Core.Type
    
    107
    +import GHC.Core.Lint        ( lintMessage )
    
    107 108
     
    
    108 109
     import GHC.Types.Basic      ( TopLevelFlag(..), isTopLevel, isMarkedCbv )
    
    109 110
     import GHC.Types.CostCentre ( isCurrentCCS )
    
    ... ... @@ -148,8 +149,7 @@ lintStgTopBindings platform logger diag_opts opts extra_vars this_mod unarised w
    148 149
           Nothing  ->
    
    149 150
             return ()
    
    150 151
           Just msg -> do
    
    151
    -        logMsg logger Err.MCInfo noSrcSpan   -- See Note [MCInfo for Lint] in "GHC.Core.Lint"
    
    152
    -          $ withPprStyle defaultDumpStyle
    
    152
    +        lintMessage logger
    
    153 153
               (vcat [ text "*** Stg Lint ErrMsgs: in" <+>
    
    154 154
                             text whodunit <+> text "***",
    
    155 155
                       msg,
    

  • compiler/GHC/Tc/Utils/Monad.hs
    ... ... @@ -2351,8 +2351,7 @@ failIfM msg = do
    2351 2351
         env <- getLclEnv
    
    2352 2352
         let full_msg = (if_loc env <> colon) $$ nest 2 msg
    
    2353 2353
         logger <- getLogger
    
    2354
    -    liftIO (logMsg logger MCFatal
    
    2355
    -             noSrcSpan $ withPprStyle defaultErrStyle full_msg)
    
    2354
    +    liftIO $ fatalErrorMsg logger full_msg
    
    2356 2355
         failM
    
    2357 2356
     
    
    2358 2357
     --------------------
    
    ... ... @@ -2384,10 +2383,7 @@ forkM doc thing_inside
    2384 2383
                           logger <- getLogger
    
    2385 2384
                           let msg = hang (text "forkM failed:" <+> doc)
    
    2386 2385
                                        2 (text (show exn))
    
    2387
    -                      liftIO $ logMsg logger
    
    2388
    -                                         MCFatal
    
    2389
    -                                         noSrcSpan
    
    2390
    -                                         $ withPprStyle defaultErrStyle msg
    
    2386
    +                      liftIO $ fatalErrorMsg logger msg
    
    2391 2387
                     ; traceIf (text "} ending fork (badly)" <+> doc)
    
    2392 2388
                     ; pgmError "Cannot continue after interface file error" }
    
    2393 2389
         }