Cheng Shao pushed to branch wip/ci-note-treeless at Glasgow Haskell Compiler / GHC

Commits:

10 changed files:

Changes:

  • .gitlab/test-metrics.sh
    ... ... @@ -17,12 +17,15 @@ fail() {
    17 17
     
    
    18 18
     function pull() {
    
    19 19
       local ref="refs/notes/$REF"
    
    20
    -  # 2023-10-04: `git fetch` started failing, first on Darwin in CI and then on
    
    21
    -  # Linux locally, both using git version 2.40.1. See #24055. One workaround is
    
    22
    -  # to set a larger http.postBuffer, although this is definitely a workaround.
    
    23
    -  # The default should work just fine. The error could be in git, GitLab, or
    
    24
    -  # perhaps the networking tube (including all proxies etc) between the two.
    
    25
    -  run git -c http.postBuffer=2097152 fetch -f "$NOTES_ORIGIN" "$ref:$ref"
    
    20
    +
    
    21
    +  # Fetch performance notes from a dedicated promisor remote using a
    
    22
    +  # treeless filter, so that individual note blobs are fetched lazily
    
    23
    +  # as needed.
    
    24
    +  git remote add perf-notes "$NOTES_ORIGIN" || true
    
    25
    +  git config fetch.recurseSubmodules false
    
    26
    +  git config remote.perf-notes.promisor true
    
    27
    +  git config remote.perf-notes.partialclonefilter tree:0
    
    28
    +  run git fetch --force perf-notes "$ref:$ref"
    
    26 29
       echo "perf notes ref $ref is $(git rev-parse $ref)"
    
    27 30
     }
    
    28 31
     
    
    ... ... @@ -81,4 +84,3 @@ case $1 in
    81 84
       pull) pull ;;
    
    82 85
       *) fail "Invalid mode $1" ;;
    
    83 86
     esac
    84
    -

  • compiler/GHC/Cmm/Opt.hs
    ... ... @@ -395,26 +395,39 @@ cmmMachOpFoldM platform mop [x, (CmmLit (CmmInt 1 rep))]
    395 395
         one  = CmmLit (CmmInt 1 (wordWidth platform))
    
    396 396
     
    
    397 397
     -- Now look for multiplication/division by powers of 2 (integers).
    
    398
    -
    
    399
    -cmmMachOpFoldM platform mop [x, (CmmLit (CmmInt n _))]
    
    398
    +--
    
    399
    +-- Naively this is as simple a matter as left/right bit shifts,
    
    400
    +-- but the Cmm representation if integral values quickly complicated the matter.
    
    401
    +--
    
    402
    +-- We must carefully narrow the value to be within the range of values for the
    
    403
    +-- type's logical bit-width. However, Cmm only represents values as *signed*
    
    404
    +-- integers internally yet the logical type may be unsigned. If we are dealing
    
    405
    +-- with a negative integer type at width @_w@, the only negative number that
    
    406
    +-- wraps around to be a positive power of 2 after calling narrowU is -2^(_w - 1)
    
    407
    +-- which wraps round to 2^(_w - 1), and multiplying by -2^(_w - 1) is indeed
    
    408
    +-- the same as a left shift by (w - 1), so this is OK.
    
    409
    +--
    
    410
    +-- ToDo: See #25664 (comment 605821) describing a change to the Cmm literal representation.
    
    411
    +-- When/If this is completed, this code must be refactored to account for the explicit width sizes.
    
    412
    +cmmMachOpFoldM platform mop [x, (CmmLit (CmmInt n _w))]
    
    400 413
       = case mop of
    
    401 414
             MO_Mul rep
    
    402
    -           | Just p <- exactLog2 n ->
    
    415
    +           | Just p <- exactLog2 (narrowU rep n) ->
    
    403 416
                      Just $! (cmmMachOpFold platform (MO_Shl rep) [x, CmmLit (CmmInt p $ wordWidth platform)])
    
    404 417
             MO_U_Quot rep
    
    405
    -           | Just p <- exactLog2 n ->
    
    418
    +           | Just p <- exactLog2 (narrowU rep n) ->
    
    406 419
                      Just $! (cmmMachOpFold platform (MO_U_Shr rep) [x, CmmLit (CmmInt p $ wordWidth platform)])
    
    407 420
             MO_U_Rem rep
    
    408
    -           | Just _ <- exactLog2 n ->
    
    421
    +           | Just _ <- exactLog2 (narrowU rep n)  ->
    
    409 422
                      Just $! (cmmMachOpFold platform (MO_And rep) [x, CmmLit (CmmInt (n - 1) rep)])
    
    410 423
             MO_S_Quot rep
    
    411
    -           | Just p <- exactLog2 n,
    
    424
    +           | Just p <- exactLog2 (narrowS rep n),
    
    412 425
                  CmmReg _ <- x ->   -- We duplicate x in signedQuotRemHelper, hence require
    
    413 426
                                     -- it is a reg.  FIXME: remove this restriction.
    
    414 427
                     Just $! (cmmMachOpFold platform (MO_S_Shr rep)
    
    415 428
                       [signedQuotRemHelper rep p, CmmLit (CmmInt p $ wordWidth platform)])
    
    416 429
             MO_S_Rem rep
    
    417
    -           | Just p <- exactLog2 n,
    
    430
    +           | Just p <- exactLog2 (narrowS rep n),
    
    418 431
                  CmmReg _ <- x ->   -- We duplicate x in signedQuotRemHelper, hence require
    
    419 432
                                     -- it is a reg.  FIXME: remove this restriction.
    
    420 433
                     -- We replace (x `rem` 2^p) by (x - (x `quot` 2^p) * 2^p).
    

  • compiler/GHC/Hs/Type.hs
    ... ... @@ -640,6 +640,9 @@ hsLTyVarName = hsTyVarName . unLoc
    640 640
     hsLTyVarNames :: [LHsTyVarBndr flag (GhcPass p)] -> [IdP (GhcPass p)]
    
    641 641
     hsLTyVarNames = mapMaybe hsLTyVarName
    
    642 642
     
    
    643
    +hsQTvExplicit :: LHsQTyVars (GhcPass p) -> [LHsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p)]
    
    644
    +hsQTvExplicit = hsq_explicit
    
    645
    +
    
    643 646
     hsForAllTelescopeBndrs :: HsForAllTelescope (GhcPass p) -> [LHsTyVarBndr ForAllTyFlag (GhcPass p)]
    
    644 647
     hsForAllTelescopeBndrs (HsForAllVis   _ bndrs) = map (fmap (setHsTyVarBndrFlag Required)) bndrs
    
    645 648
     hsForAllTelescopeBndrs (HsForAllInvis _ bndrs) = map (fmap (updateHsTyVarBndrFlag Invisible)) bndrs
    

  • compiler/Language/Haskell/Syntax/Type.hs
    ... ... @@ -55,7 +55,6 @@ module Language.Haskell.Syntax.Type (
    55 55
             FieldOcc(..), LFieldOcc,
    
    56 56
     
    
    57 57
             mapHsOuterImplicit,
    
    58
    -        hsQTvExplicit,
    
    59 58
             isHsKindedTyVar
    
    60 59
         ) where
    
    61 60
     
    
    ... ... @@ -68,7 +67,6 @@ import Language.Haskell.Syntax.Specificity
    68 67
     
    
    69 68
     import GHC.Hs.Doc (LHsDoc)
    
    70 69
     import GHC.Data.FastString (FastString)
    
    71
    -import GHC.Utils.Panic( panic )
    
    72 70
     
    
    73 71
     import Data.Data hiding ( Fixity, Prefix, Infix )
    
    74 72
     import Data.Maybe
    
    ... ... @@ -326,10 +324,6 @@ data LHsQTyVars pass -- See Note [HsType binders]
    326 324
         }
    
    327 325
       | XLHsQTyVars !(XXLHsQTyVars pass)
    
    328 326
     
    
    329
    -hsQTvExplicit :: LHsQTyVars pass -> [LHsTyVarBndr (HsBndrVis pass) pass]
    
    330
    -hsQTvExplicit (HsQTvs { hsq_explicit = explicit_tvs }) = explicit_tvs
    
    331
    -hsQTvExplicit (XLHsQTyVars {})                         = panic "hsQTvExplicit"
    
    332
    -
    
    333 327
     ------------------------------------------------
    
    334 328
     --            HsOuterTyVarBndrs
    
    335 329
     -- Used to quantify the outermost type variable binders of a type that obeys
    

  • testsuite/tests/cmm/opt/T25664.hs
    1
    +{-# OPTIONS_GHC -O -fno-full-laziness #-}
    
    2
    +{-# LANGUAGE MagicHash #-}
    
    3
    +
    
    4
    +import GHC.Exts
    
    5
    +import GHC.Int
    
    6
    +
    
    7
    +mb8 :: Int8 -> Int8
    
    8
    +{-# OPAQUE mb8 #-}
    
    9
    +mb8 (I8# i) = I8# (i `quotInt8#` (noinline intToInt8# 128#))
    
    10
    +
    
    11
    +mb16 :: Int16 -> Int16
    
    12
    +{-# OPAQUE mb16 #-}
    
    13
    +mb16 (I16# i) = I16# (i `quotInt16#` (noinline intToInt16# 32768#))
    
    14
    +
    
    15
    +main :: IO ()
    
    16
    +main = print (mb8 minBound) >> print (mb16 minBound)
    
    17
    +

  • testsuite/tests/cmm/opt/T25664.stdout
    1
    +1
    
    2
    +1

  • testsuite/tests/cmm/opt/all.T
    ... ... @@ -12,3 +12,6 @@ test('T25771', [cmm_src, only_ways(['optasm']),
    12 12
                     grep_errmsg(r'(12\.345|0\.6640625)',[1]),
    
    13 13
                     ],
    
    14 14
          compile, ['-ddump-cmm'])
    
    15
    +
    
    16
    +# Cmm should correctly account for word size when performing MUL/DIV/REM by a power of 2 optimization.
    
    17
    +test('T25664', normal, compile_and_run, [''])
    \ No newline at end of file

  • utils/haddock/haddock-api/src/Haddock/Backends/LaTeX.hs
    ... ... @@ -435,7 +435,7 @@ ppFamHeader
    435 435
             | associated = id
    
    436 436
             | otherwise = (<+> keyword "family")
    
    437 437
     
    
    438
    -      famName = ppAppDocNameTyVarBndrs unicode name (hsq_explicit tvs)
    
    438
    +      famName = ppAppDocNameTyVarBndrs unicode name (hsQTvExplicitBinders tvs)
    
    439 439
     
    
    440 440
           famSig = case result of
    
    441 441
             NoSig _ -> empty
    
    ... ... @@ -644,7 +644,7 @@ ppTyVars :: RenderableBndrFlag flag => Bool -> [LHsTyVarBndr flag DocNameI] -> [
    644 644
     ppTyVars unicode tvs = map (ppHsTyVarBndr unicode . unLoc) tvs
    
    645 645
     
    
    646 646
     tyvarNames :: LHsQTyVars DocNameI -> [Maybe Name]
    
    647
    -tyvarNames = map (fmap getName . hsLTyVarNameI) . hsQTvExplicit
    
    647
    +tyvarNames = map (fmap getName . hsLTyVarNameI) . hsQTvExplicitBinders
    
    648 648
     
    
    649 649
     declWithDoc :: LaTeX -> Maybe LaTeX -> LaTeX
    
    650 650
     declWithDoc decl doc =
    

  • utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
    ... ... @@ -468,7 +468,7 @@ ppTySyn
    468 468
           hdr =
    
    469 469
             hsep
    
    470 470
               ( [keyword "type", ppBinder summary occ]
    
    471
    -              ++ ppTyVars unicode qual (hsQTvExplicit ltyvars)
    
    471
    +              ++ ppTyVars unicode qual (hsQTvExplicitBinders ltyvars)
    
    472 472
               )
    
    473 473
           full = hdr <+> def
    
    474 474
           def = case unLoc ltype of
    
    ... ... @@ -595,7 +595,7 @@ ppFamHeader
    595 595
       qual =
    
    596 596
         hsep
    
    597 597
           [ ppFamilyLeader associated info
    
    598
    -      , ppAppDocNameTyVarBndrs summary unicode qual name (hsq_explicit tvs)
    
    598
    +      , ppAppDocNameTyVarBndrs summary unicode qual name (hsQTvExplicitBinders tvs)
    
    599 599
           , ppResultSig result unicode qual
    
    600 600
           , injAnn
    
    601 601
           , whereBit
    
    ... ... @@ -760,7 +760,7 @@ ppClassHdr
    760 760
     ppClassHdr summ lctxt n tvs fds unicode qual =
    
    761 761
       keyword "class"
    
    762 762
         <+> (if not (null $ fromMaybeContext lctxt) then ppLContext lctxt unicode qual HideEmptyContexts else noHtml)
    
    763
    -    <+> ppAppDocNameTyVarBndrs summ unicode qual n (hsQTvExplicit tvs)
    
    763
    +    <+> ppAppDocNameTyVarBndrs summ unicode qual n (hsQTvExplicitBinders tvs)
    
    764 764
         <+> ppFds fds unicode qual
    
    765 765
     
    
    766 766
     ppFds :: [LHsFunDep DocNameI] -> Unicode -> Qualification -> Html
    
    ... ... @@ -1656,7 +1656,7 @@ ppDataHeader
    1656 1656
           ppLContext ctxt unicode qual HideEmptyContexts
    
    1657 1657
           <+>
    
    1658 1658
           -- T a b c ..., or a :+: b
    
    1659
    -      ppAppDocNameTyVarBndrs summary unicode qual name (hsQTvExplicit tvs)
    
    1659
    +      ppAppDocNameTyVarBndrs summary unicode qual name (hsQTvExplicitBinders tvs)
    
    1660 1660
           <+> case ks of
    
    1661 1661
             Nothing -> mempty
    
    1662 1662
             Just (L _ x) -> dcolon unicode <+> ppKind unicode qual x
    

  • utils/haddock/haddock-api/src/Haddock/GhcUtils.hs
    ... ... @@ -333,9 +333,12 @@ lHsQTyVarsToTypes tvs =
    333 333
       [ HsValArg noExtField $ noLocA (case hsLTyVarName tv of
    
    334 334
           Nothing -> HsWildCardTy noExtField
    
    335 335
           Just nm -> HsTyVar noAnn NotPromoted (noLocA $ noUserRdr nm))
    
    336
    -  | tv <- hsQTvExplicit tvs
    
    336
    +  | tv <- hsq_explicit tvs
    
    337 337
       ]
    
    338 338
     
    
    339
    +hsQTvExplicitBinders :: LHsQTyVars DocNameI -> [LHsTyVarBndr (HsBndrVis DocNameI) DocNameI]
    
    340
    +hsQTvExplicitBinders = hsq_explicit
    
    341
    +
    
    339 342
     --------------------------------------------------------------------------------
    
    340 343
     
    
    341 344
     -- * Making abstract declarations